Changeset View
Standalone View
applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml
Show All 37 Lines | 34 | status: { | |||
---|---|---|---|---|---|
38 | case "NeedsAttention": | 38 | case "NeedsAttention": | ||
39 | return PlasmaCore.Types.NeedsAttentionStatus; | 39 | return PlasmaCore.Types.NeedsAttentionStatus; | ||
40 | //just assume passive | 40 | //just assume passive | ||
41 | default: | 41 | default: | ||
42 | return PlasmaCore.Types.PassiveStatus; | 42 | return PlasmaCore.Types.PassiveStatus; | ||
43 | } | 43 | } | ||
44 | } | 44 | } | ||
45 | 45 | | |||
46 | onStatusChanged: { | | |||
47 | //binding is not working in PlasmaCore.IconItem | | |||
48 | iconItem.source = status === PlasmaCore.Types.NeedsAttentionStatus ? (AttentionIcon ? AttentionIcon : AttentionIconName) : (Icon ? Icon : IconName) | | |||
49 | } | | |||
50 | | ||||
51 | iconItem: iconItem | 46 | iconItem: iconItem | ||
52 | 47 | | |||
53 | PlasmaCore.IconItem { | 48 | PlasmaCore.IconItem { | ||
54 | id: iconItem | 49 | id: iconItem | ||
55 | source: Icon ? Icon : IconName | 50 | source: { | ||
51 | if (taskIcon.status === PlasmaCore.Types.NeedsAttentionStatus) { | ||||
52 | if (AttentionIcon) { | ||||
kmaterka: I know... Do you know another way how to check if QVariant(QIcon) is null? I know that I can… | |||||
The easiest alternative is to do it earlier in the source itself. Instead of supplying a valid QVariant with a null icon, we can export a null QVariant. i.e statusnotifiericonsource.cpp Then the regular QML tests will work just fine. davidedmundson: The easiest alternative is to do it earlier in the source itself.
Instead of supplying a valid… | |||||
53 | return AttentionIcon | ||||
54 | } | ||||
55 | if (AttentionIconName) { | ||||
56 | return AttentionIconName | ||||
57 | } | ||||
58 | } | ||||
59 | return Icon ? Icon : IconName | ||||
davidedmundson: Do we need the same thing for this check? | |||||
davidedmundson: Edit. ignore me. | |||||
I had few worries about this approach but I tested with several combinations. Additional comment for anyone wondering how it is working. setData(QStringLiteral("AttentionIcon"), QIcon()); setData(QStringLiteral("Icon"), QIcon()); It is required to setup role names - invalid QVariant() removes role name (check DataContainer::setData). All role names must be initialized, if not QML won't recognize it later. Fortunately, on any update all fields, including icons, are updated. Setting QVariant() will remove value entirely. In fact, it removes the role name, but as roles are cached, it is not making any harm. kmaterka: I had few worries about this approach but I tested with several combinations.
Additional… | |||||
60 | } | ||||
61 | | ||||
56 | width: Math.min(parent.width, parent.height) | 62 | width: Math.min(parent.width, parent.height) | ||
57 | height: width | 63 | height: width | ||
58 | active: taskIcon.containsMouse | 64 | active: taskIcon.containsMouse | ||
59 | 65 | | |||
60 | anchors { | 66 | anchors { | ||
61 | left: parent.left | 67 | left: parent.left | ||
62 | verticalCenter: parent.verticalCenter | 68 | verticalCenter: parent.verticalCenter | ||
63 | } | 69 | } | ||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |
I know... Do you know another way how to check if QVariant(QIcon) is null? I know that I can create simple native method in systemtray.cpp for that - will it be better?