Skip to content

Commit 9f2b3b3

Browse files
committed
Fix using SnoreToast from installed folder
Fix change delivered in #1240
1 parent d824d98 commit 9f2b3b3

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/SystemNotifications/SystemNotificationWindows.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ typedef NTSTATUS (NTAPI *PNTQUERYWNFSTATEDATA)(
3838
_Inout_ PULONG BufferSize);
3939

4040
const QString SystemNotificationWindows::SNORETOAST_EXE = "SnoreToast.exe";
41-
const QString SystemNotificationWindows::SNORETOAST= [](){ return findSnoreToast(QDir::currentPath()); }();
4241
const QString SystemNotificationWindows::SNORETOAST_INSTALL= "-install";
42+
const QString SystemNotificationWindows::APP_ID = "Moolticute";
4343
const QString SystemNotificationWindows::NOTIFICATIONS_SETTING_REGENTRY = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Notifications\\Settings";
4444
const QString SystemNotificationWindows::DND_ENABLED_REGENTRY = "NOC_GLOBAL_SETTING_TOASTS_ENABLED";
4545
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
101101
notificationMap->insert(notificationId, proc);
102102
connect(proc, static_cast<CallbackType>(&QProcess::finished), this, &SystemNotificationWindows::callbackFunction);
103103
QStringList choiceArgs = { "-t", title, "-m", text, "-b", buttonString, "-id", QString::number(notificationId++), "-p", ICON, "-w"};
104-
proc->start(SNORETOAST, choiceArgs);
104+
proc->start(getSnoreToast(), choiceArgs);
105105
}
106106

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

116116
bool SystemNotificationWindows::displayLoginRequestNotification(const QString &service, QString &loginName, QString message)
@@ -155,6 +155,12 @@ bool SystemNotificationWindows::displayDomainSelectionNotification(const QString
155155
}
156156
}
157157

158+
QString SystemNotificationWindows::getSnoreToast()
159+
{
160+
static const QString SNORE_TOAST = findSnoreToast(QDir::currentPath());
161+
return SNORE_TOAST;
162+
}
163+
158164
QString SystemNotificationWindows::findSnoreToast(QString path)
159165
{
160166
QDirIterator it{path, QDirIterator::Subdirectories};
@@ -182,7 +188,7 @@ void SystemNotificationWindows::installSnoreToast()
182188
{
183189
if (IS_WIN10_OR_ABOVE)
184190
{
185-
process->start(SNORETOAST, {SNORETOAST_INSTALL});
191+
process->start(getSnoreToast(), {SNORETOAST_INSTALL});
186192
}
187193
}
188194

src/SystemNotifications/SystemNotificationWindows.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ class SystemNotificationWindows : public ISystemNotification
3030
virtual bool displayLoginRequestNotification(const QString& service, QString &loginName, QString message) override;
3131
virtual bool displayDomainSelectionNotification(const QString& domain, const QString& subdomain, QString &serviceName, QString message) override;
3232

33+
static inline QString getSnoreToast();
3334
static QString findSnoreToast(QString path);
3435

3536
const static QString SNORETOAST_EXE;
36-
const static QString SNORETOAST;
3737
const static QString SNORETOAST_INSTALL;
38+
const static QString APP_ID;
3839
const static QString NOTIFICATIONS_SETTING_REGENTRY;
3940
const static QString DND_ENABLED_REGENTRY;
4041
const static QString TOAST_ENABLED_SETTING_REGPATH;

0 commit comments

Comments
 (0)