mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 08:16:16 -07:00
Fix notifications with xfce4-notifyd.
This commit is contained in:
parent
f898443e78
commit
959cbb9308
1 changed files with 16 additions and 9 deletions
|
@ -1167,15 +1167,22 @@ void MainWindow::showNotificationBaloon(QString title, QString msg) const {
|
||||||
org::freedesktop::Notifications notifications("org.freedesktop.Notifications",
|
org::freedesktop::Notifications notifications("org.freedesktop.Notifications",
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
QDBusConnection::sessionBus());
|
QDBusConnection::sessionBus());
|
||||||
if (notifications.isValid()) {
|
// Testing for 'notifications.isValid()' isn't helpful here.
|
||||||
QVariantMap hints;
|
// If the notification daemon is configured to run 'as needed'
|
||||||
hints["desktop-entry"] = "qBittorrent";
|
// the above check can be false if the daemon wasn't started
|
||||||
QDBusPendingReply<uint> reply = notifications.Notify("qBittorrent", 0, "qbittorrent", title,
|
// by another application. In this case DBus will be able to
|
||||||
msg, QStringList(), hints, -1);
|
// start the notification daemon and complete our request. Such
|
||||||
reply.waitForFinished();
|
// a daemon is xfce4-notifyd, DBus autostarts it and after
|
||||||
if (!reply.isError())
|
// some inactivity shuts it down. Other DEs, like GNOME, choose
|
||||||
return;
|
// to start their daemons at the session startup and have it sit
|
||||||
}
|
// idling for the whole session.
|
||||||
|
QVariantMap hints;
|
||||||
|
hints["desktop-entry"] = "qBittorrent";
|
||||||
|
QDBusPendingReply<uint> reply = notifications.Notify("qBittorrent", 0, "qbittorrent", title,
|
||||||
|
msg, QStringList(), hints, -1);
|
||||||
|
reply.waitForFinished();
|
||||||
|
if (!reply.isError())
|
||||||
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (systrayIcon && QSystemTrayIcon::supportsMessages())
|
if (systrayIcon && QSystemTrayIcon::supportsMessages())
|
||||||
systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
|
systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue