@@ -37,7 +37,8 @@ typedef NTSTATUS (NTAPI *PNTQUERYWNFSTATEDATA)(
3737 _Out_writes_bytes_to_opt_ (*BufferSize, *BufferSize) PVOID Buffer,
3838 _Inout_ PULONG BufferSize);
3939
40- const QString SystemNotificationWindows::SNORETOAST= " SnoreToast.exe" ;
40+ const QString SystemNotificationWindows::SNORETOAST_EXE = " SnoreToast.exe" ;
41+ const QString SystemNotificationWindows::SNORETOAST= [](){ return findSnoreToast (QDir::currentPath ()); }();
4142const QString SystemNotificationWindows::SNORETOAST_INSTALL= " -install" ;
4243const QString SystemNotificationWindows::NOTIFICATIONS_SETTING_REGENTRY = " HKEY_CURRENT_USER\\ SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Notifications\\ Settings" ;
4344const QString SystemNotificationWindows::DND_ENABLED_REGENTRY = " NOC_GLOBAL_SETTING_TOASTS_ENABLED" ;
@@ -53,7 +54,6 @@ SystemNotificationWindows::SystemNotificationWindows(QObject *parent)
5354 process = new QProcess ();
5455 notificationMap = new NotificationMap ();
5556 messageMap = new MessageMap ();
56- installSnoreToast ();
5757}
5858
5959SystemNotificationWindows::~SystemNotificationWindows ()
@@ -155,6 +155,29 @@ bool SystemNotificationWindows::displayDomainSelectionNotification(const QString
155155 }
156156}
157157
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+
158181void SystemNotificationWindows::installSnoreToast ()
159182{
160183 if (IS_WIN10_OR_ABOVE)
0 commit comments