diff options
| author | Carl Schwan <carl.schwan@kdab.com> | 2023-04-03 18:05:52 +0200 |
|---|---|---|
| committer | Carl Schwan <carl.schwan@kdab.com> | 2023-04-04 23:53:37 +0200 |
| commit | ac973cb74fecdaedf31922dfd48ea522a7af8f51 (patch) | |
| tree | 411f48905d17e475bc8f6cede51d21d877b87244 /src/gui/platform/unix/qgenericunixservices.cpp | |
| parent | 447f3ade9a284d52552352e2752c53be2cf0a57e (diff) | |
Implement setBadgeNumber for xcb backend
This use the unity launcher specification which is defined here
https://wiki.ubuntu.com/Unity/LauncherAPI
This spec is used by Plasma and Unity. On other Linux desktop platform
where the unity DBus interface is not detected this is no-op.
Change-Id: I81a9b95fe4886ad597bb4e775641926b161c49a5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src/gui/platform/unix/qgenericunixservices.cpp')
| -rw-r--r-- | src/gui/platform/unix/qgenericunixservices.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gui/platform/unix/qgenericunixservices.cpp b/src/gui/platform/unix/qgenericunixservices.cpp index 4e27a33af5a..e834ad1f079 100644 --- a/src/gui/platform/unix/qgenericunixservices.cpp +++ b/src/gui/platform/unix/qgenericunixservices.cpp @@ -575,6 +575,37 @@ bool QGenericUnixServices::hasCapability(Capability capability) const return false; } +void QGenericUnixServices::setApplicationBadge(qint64 number) +{ +#if QT_CONFIG(dbus) + if (qGuiApp->desktopFileName().isEmpty()) { + qWarning("QGuiApplication::desktopFileName() is empty"); + return; + } + + + const QString launcherUrl = QStringLiteral("application://") + qGuiApp->desktopFileName() + QStringLiteral(".desktop"); + const qint64 count = qBound(0, number, 9999); + QVariantMap dbusUnityProperties; + + if (count > 0) { + dbusUnityProperties[QStringLiteral("count")] = count; + dbusUnityProperties[QStringLiteral("count-visible")] = true; + } else { + dbusUnityProperties[QStringLiteral("count-visible")] = false; + } + + auto signal = QDBusMessage::createSignal(QStringLiteral("/com/canonical/unity/launcherentry/") + + qGuiApp->applicationName(), QStringLiteral("com.canonical.Unity.LauncherEntry"), QStringLiteral("Update")); + + signal.setArguments({launcherUrl, dbusUnityProperties}); + + QDBusConnection::sessionBus().send(signal); +#else + Q_UNUSED(number) +#endif +} + QT_END_NAMESPACE #include "qgenericunixservices.moc" |
