diff --git a/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml b/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml --- a/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml +++ b/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml @@ -43,16 +43,25 @@ } } - onStatusChanged: { - //binding is not working in PlasmaCore.IconItem - iconItem.source = status === PlasmaCore.Types.NeedsAttentionStatus ? (AttentionIcon ? AttentionIcon : AttentionIconName) : (Icon ? Icon : IconName) - } - iconItem: iconItem PlasmaCore.IconItem { id: iconItem - source: Icon ? Icon : IconName + source: { + if (taskIcon.status === PlasmaCore.Types.NeedsAttentionStatus) { + if (plasmoid.nativeInterface.isValidIcon(AttentionIcon)) { + return AttentionIcon + } + if (AttentionIconName) { + return AttentionIconName + } + } + if (plasmoid.nativeInterface.isValidIcon(Icon)) { + return Icon + } + return IconName + } + width: Math.min(parent.width, parent.height) height: width active: taskIcon.containsMouse diff --git a/applets/systemtray/systemtray.h b/applets/systemtray/systemtray.h --- a/applets/systemtray/systemtray.h +++ b/applets/systemtray/systemtray.h @@ -101,6 +101,11 @@ Q_INVOKABLE bool isSystemTrayApplet(const QString &appletId); + /** + * Checks if the icon is valid (not null). + */ + Q_INVOKABLE bool isValidIcon(const QVariant &value) const; + private Q_SLOTS: void serviceNameFetchFinished(QDBusPendingCallWatcher* watcher, const QDBusConnection &connection); void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner); diff --git a/applets/systemtray/systemtray.cpp b/applets/systemtray/systemtray.cpp --- a/applets/systemtray/systemtray.cpp +++ b/applets/systemtray/systemtray.cpp @@ -349,6 +349,15 @@ return m_systrayApplets.contains(appletId); } +bool SystemTray::isValidIcon(const QVariant &value) const +{ + if (!value.isValid() || value.isNull() || !value.canConvert()) { + return false; + } + QIcon icon = value.value(); + return !icon.name().isEmpty() || !icon.isNull(); +} + void SystemTray::restoreContents(KConfigGroup &group) { Q_UNUSED(group);