utils: fix desktopNotify

This commit is contained in:
tobtoht 2023-03-29 10:15:33 +02:00
parent afbbeee44f
commit 6b065acdae
No known key found for this signature in database
GPG key ID: E45B10DD027D2472

View file

@ -494,12 +494,14 @@ void externalLinkWarning(QWidget *parent, const QString &url){
} }
void desktopNotify(const QString &title, const QString &message, int duration) { void desktopNotify(const QString &title, const QString &message, int duration) {
if (!Config::hideNotifications) if (config()->get(Config::hideNotifications).toBool()) {
{ return;
}
QStringList notify_send = QStringList() << title << message << "-t" << QString::number(duration); QStringList notify_send = QStringList() << title << message << "-t" << QString::number(duration);
QStringList kdialog = QStringList() << title << message; QStringList kdialog = QStringList() << title << message;
QStringList macos = QStringList() << "-e" << QString(R"(display notification "%1" with title "%2")").arg(message).arg(title); QStringList macos = QStringList() << "-e" << QString(R"(display notification "%1" with title "%2")").arg(message).arg(title);
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
QProcess process; QProcess process;
if (fileExists("/usr/bin/kdialog")) if (fileExists("/usr/bin/kdialog"))
process.start("/usr/bin/kdialog", kdialog); process.start("/usr/bin/kdialog", kdialog);
@ -508,15 +510,14 @@ void desktopNotify(const QString &title, const QString &message, int duration) {
process.waitForFinished(-1); process.waitForFinished(-1);
QString stdout = process.readAllStandardOutput(); QString stdout = process.readAllStandardOutput();
QString stderr = process.readAllStandardError(); QString stderr = process.readAllStandardError();
#elif defined(Q_OS_MACOS) #elif defined(Q_OS_MACOS)
QProcess process; QProcess process;
// @TODO: need to escape special chars with "\" // @TODO: need to escape special chars with "\"
process.start("osascript", macos); process.start("osascript", macos);
process.waitForFinished(-1); process.waitForFinished(-1);
QString stdout = process.readAllStandardOutput(); QString stdout = process.readAllStandardOutput();
QString stderr = process.readAllStandardError(); QString stderr = process.readAllStandardError();
#endif #endif
}
} }
QString displayAddress(const QString& address, int sections, const QString& sep) { QString displayAddress(const QString& address, int sections, const QString& sep) {