Skip to content

Commit

Permalink
Merge pull request #1243 from deXol/develop
Browse files Browse the repository at this point in the history
Fix using SnoreToast from installed folder
  • Loading branch information
limpkin authored Sep 13, 2024
2 parents ae23b62 + 9f2b3b3 commit ab6dcfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/SystemNotifications/SystemNotificationWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ typedef NTSTATUS (NTAPI *PNTQUERYWNFSTATEDATA)(
_Inout_ PULONG BufferSize);

const QString SystemNotificationWindows::SNORETOAST_EXE = "SnoreToast.exe";
const QString SystemNotificationWindows::SNORETOAST= [](){ return findSnoreToast(QDir::currentPath()); }();
const QString SystemNotificationWindows::SNORETOAST_INSTALL= "-install";
const QString SystemNotificationWindows::APP_ID = "Moolticute";
const QString SystemNotificationWindows::NOTIFICATIONS_SETTING_REGENTRY = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Notifications\\Settings";
const QString SystemNotificationWindows::DND_ENABLED_REGENTRY = "NOC_GLOBAL_SETTING_TOASTS_ENABLED";
const QString SystemNotificationWindows::TOAST_ENABLED_SETTING_REGPATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\PushNotifications";
Expand Down Expand Up @@ -101,7 +101,7 @@ void SystemNotificationWindows::createButtonChoiceNotification(const QString &ti
notificationMap->insert(notificationId, proc);
connect(proc, static_cast<CallbackType>(&QProcess::finished), this, &SystemNotificationWindows::callbackFunction);
QStringList choiceArgs = { "-t", title, "-m", text, "-b", buttonString, "-id", QString::number(notificationId++), "-p", ICON, "-w"};
proc->start(SNORETOAST, choiceArgs);
proc->start(getSnoreToast(), choiceArgs);
}

void SystemNotificationWindows::createTextBoxNotification(const QString &title, const QString text)
Expand All @@ -110,7 +110,7 @@ void SystemNotificationWindows::createTextBoxNotification(const QString &title,
notificationMap->insert(notificationId, proc);
QStringList textNotiArgs = { "-t", title, "-m", text, "-tb", "-id", QString::number(notificationId++), "-p", ICON, "-w"};
connect(proc, static_cast<CallbackType>(&QProcess::finished), this, &SystemNotificationWindows::callbackFunction);
proc->start(SNORETOAST, textNotiArgs);
proc->start(getSnoreToast(), textNotiArgs);
}

bool SystemNotificationWindows::displayLoginRequestNotification(const QString &service, QString &loginName, QString message)
Expand Down Expand Up @@ -155,6 +155,12 @@ bool SystemNotificationWindows::displayDomainSelectionNotification(const QString
}
}

QString SystemNotificationWindows::getSnoreToast()
{
static const QString SNORE_TOAST = findSnoreToast(QDir::currentPath());
return SNORE_TOAST;
}

QString SystemNotificationWindows::findSnoreToast(QString path)
{
QDirIterator it{path, QDirIterator::Subdirectories};
Expand Down Expand Up @@ -182,7 +188,7 @@ void SystemNotificationWindows::installSnoreToast()
{
if (IS_WIN10_OR_ABOVE)
{
process->start(SNORETOAST, {SNORETOAST_INSTALL});
process->start(getSnoreToast(), {SNORETOAST_INSTALL});
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/SystemNotifications/SystemNotificationWindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ class SystemNotificationWindows : public ISystemNotification
virtual bool displayLoginRequestNotification(const QString& service, QString &loginName, QString message) override;
virtual bool displayDomainSelectionNotification(const QString& domain, const QString& subdomain, QString &serviceName, QString message) override;

static inline QString getSnoreToast();
static QString findSnoreToast(QString path);

const static QString SNORETOAST_EXE;
const static QString SNORETOAST;
const static QString SNORETOAST_INSTALL;
const static QString APP_ID;
const static QString NOTIFICATIONS_SETTING_REGENTRY;
const static QString DND_ENABLED_REGENTRY;
const static QString TOAST_ENABLED_SETTING_REGPATH;
Expand Down

0 comments on commit ab6dcfb

Please sign in to comment.