@@ -37,7 +37,8 @@ typedef NTSTATUS (NTAPI *PNTQUERYWNFSTATEDATA)(
37
37
_Out_writes_bytes_to_opt_ (*BufferSize, *BufferSize) PVOID Buffer,
38
38
_Inout_ PULONG BufferSize);
39
39
40
- const QString SystemNotificationWindows::SNORETOAST= " SnoreToast.exe" ;
40
+ const QString SystemNotificationWindows::SNORETOAST_EXE = " SnoreToast.exe" ;
41
+ const QString SystemNotificationWindows::SNORETOAST= [](){ return findSnoreToast (QDir::currentPath ()); }();
41
42
const QString SystemNotificationWindows::SNORETOAST_INSTALL= " -install" ;
42
43
const QString SystemNotificationWindows::NOTIFICATIONS_SETTING_REGENTRY = " HKEY_CURRENT_USER\\ SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Notifications\\ Settings" ;
43
44
const QString SystemNotificationWindows::DND_ENABLED_REGENTRY = " NOC_GLOBAL_SETTING_TOASTS_ENABLED" ;
@@ -53,7 +54,6 @@ SystemNotificationWindows::SystemNotificationWindows(QObject *parent)
53
54
process = new QProcess ();
54
55
notificationMap = new NotificationMap ();
55
56
messageMap = new MessageMap ();
56
- installSnoreToast ();
57
57
}
58
58
59
59
SystemNotificationWindows::~SystemNotificationWindows ()
@@ -155,6 +155,29 @@ bool SystemNotificationWindows::displayDomainSelectionNotification(const QString
155
155
}
156
156
}
157
157
158
+ QString SystemNotificationWindows::findSnoreToast (QString path)
159
+ {
160
+ QDirIterator it{path, QDirIterator::Subdirectories};
161
+ while (it.hasNext ())
162
+ {
163
+ QString filename = it.next ();
164
+ QFileInfo file{filename};
165
+
166
+ if (file.isDir ())
167
+ {
168
+ continue ;
169
+ }
170
+
171
+ if (file.fileName ().contains (SNORETOAST_EXE, Qt::CaseInsensitive))
172
+ {
173
+ qDebug () << " SnoreToast path: " << file.absoluteFilePath ();
174
+ return file.absoluteFilePath ();
175
+ }
176
+ }
177
+ qWarning () << " SnoreToast is not available." ;
178
+ return " " ;
179
+ }
180
+
158
181
void SystemNotificationWindows::installSnoreToast ()
159
182
{
160
183
if (IS_WIN10_OR_ABOVE)
0 commit comments