Skip to content

Commit ae23b62

Browse files
authored
Merge pull request #1240 from deXol/develop
Use SnoreToast from installed folder, fix #1238
2 parents 362365e + d824d98 commit ae23b62

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/SystemNotifications/SystemNotificationWindows.cpp

+25-2
Original file line numberDiff line numberDiff line change
@@ -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()); }();
4142
const QString SystemNotificationWindows::SNORETOAST_INSTALL= "-install";
4243
const QString SystemNotificationWindows::NOTIFICATIONS_SETTING_REGENTRY = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Notifications\\Settings";
4344
const 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

5959
SystemNotificationWindows::~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+
158181
void SystemNotificationWindows::installSnoreToast()
159182
{
160183
if (IS_WIN10_OR_ABOVE)

src/SystemNotifications/SystemNotificationWindows.h

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ 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 QString findSnoreToast(QString path);
34+
35+
const static QString SNORETOAST_EXE;
3336
const static QString SNORETOAST;
3437
const static QString SNORETOAST_INSTALL;
3538
const static QString NOTIFICATIONS_SETTING_REGENTRY;

0 commit comments

Comments
 (0)