diff --git a/src/SystemNotifications/SystemNotificationWindows.cpp b/src/SystemNotifications/SystemNotificationWindows.cpp index 0aa15181..77a0137d 100644 --- a/src/SystemNotifications/SystemNotificationWindows.cpp +++ b/src/SystemNotifications/SystemNotificationWindows.cpp @@ -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"; @@ -101,7 +101,7 @@ void SystemNotificationWindows::createButtonChoiceNotification(const QString &ti notificationMap->insert(notificationId, proc); connect(proc, static_cast(&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) @@ -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(&QProcess::finished), this, &SystemNotificationWindows::callbackFunction); - proc->start(SNORETOAST, textNotiArgs); + proc->start(getSnoreToast(), textNotiArgs); } bool SystemNotificationWindows::displayLoginRequestNotification(const QString &service, QString &loginName, QString message) @@ -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}; @@ -182,7 +188,7 @@ void SystemNotificationWindows::installSnoreToast() { if (IS_WIN10_OR_ABOVE) { - process->start(SNORETOAST, {SNORETOAST_INSTALL}); + process->start(getSnoreToast(), {SNORETOAST_INSTALL}); } } diff --git a/src/SystemNotifications/SystemNotificationWindows.h b/src/SystemNotifications/SystemNotificationWindows.h index 747d93bb..a49710ff 100644 --- a/src/SystemNotifications/SystemNotificationWindows.h +++ b/src/SystemNotifications/SystemNotificationWindows.h @@ -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;