Changeset View
Standalone View
applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml
Show All 20 Lines | |||||
21 | import org.kde.plasma.core 2.0 as PlasmaCore | 21 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
22 | 22 | | |||
23 | AbstractItem { | 23 | AbstractItem { | ||
24 | id: taskIcon | 24 | id: taskIcon | ||
25 | 25 | | |||
26 | itemId: model.Id | 26 | itemId: model.Id | ||
27 | text: model.Title | 27 | text: model.Title | ||
28 | mainText: model.ToolTipTitle !== "" ? model.ToolTipTitle : model.Title | 28 | mainText: model.ToolTipTitle !== "" ? model.ToolTipTitle : model.Title | ||
29 | subText: model.ToolTipSubTitle | 29 | subText: model.ToolTipSubTitle | ||
30 | textFormat: Text.AutoText | 30 | textFormat: Text.AutoText | ||
kmaterka: You need to change here as well. | |||||
31 | 31 | | |||
32 | PlasmaCore.IconItem { | 32 | PlasmaCore.IconItem { | ||
33 | id: iconItem | 33 | id: iconItem | ||
34 | parent: taskIcon.iconContainer | 34 | parent: taskIcon.iconContainer | ||
35 | anchors.fill: iconItem.parent | 35 | anchors.fill: iconItem.parent | ||
36 | 36 | | |||
37 | source: { | 37 | source: { | ||
38 | if (model.status === PlasmaCore.Types.NeedsAttentionStatus) { | 38 | if (model.status === PlasmaCore.Types.NeedsAttentionStatus) { | ||
39 | if (model.AttentionIcon) { | | |||
40 | return model.AttentionIcon | | |||
41 | } | | |||
42 | if (model.AttentionIconName) { | 39 | if (model.AttentionIconName) { | ||
43 | return model.AttentionIconName | 40 | return model.AttentionIconName | ||
44 | } | 41 | } | ||
42 | if (model.AttentionIconPixmap) { | ||||
43 | return model.AttentionIconPixmap | ||||
44 | } | ||||
45 | } | 45 | } | ||
46 | return model.Icon ? model.Icon : model.IconName | 46 | return model.IconName ? model.IconName : model.IconPixmap | ||
47 | } | 47 | } | ||
48 | active: taskIcon.containsMouse | 48 | active: taskIcon.containsMouse | ||
49 | } | 49 | } | ||
50 | // IconItem.overlays only supports names so we need a second item for the overlay, using the same | ||||
Should overlay pixmaps be supported in PlasmaCore.IconItem? I guess that would require changes in KIconLoader as well. kmaterka: Should overlay pixmaps be supported in `PlasmaCore.IconItem`? I guess that would require… | |||||
51 | // positioning that KIconLoader::drawOverlays uses that IconItem uses internally | ||||
52 | PlasmaCore.IconItem { | ||||
53 | id: overlayIconItem | ||||
kmaterka: add `parent: iconItem.parent` | |||||
54 | parent: iconItem.parent | ||||
55 | source: { | ||||
56 | if (model.OverlayIconName) { | ||||
57 | return model.OverlayIconName | ||||
58 | } | ||||
59 | if (model.OverlayIconPixmap) { | ||||
60 | return model.OverlayIconPixmap | ||||
61 | } | ||||
62 | return ""; | ||||
63 | } | ||||
64 | width: { | ||||
In StatusNotifierItemSource::overlayIcon() it is "width <= 32". There is a pre-existing inconsistency between StatusNotifierItemSource and IconItem/KIconLoader. kmaterka: In [[ https://phabricator.kde.org/source/plasma… | |||||
65 | if (iconItem.width < units.iconSizes.medium) { | ||||
66 | return units.iconSizes.small / 2; | ||||
67 | } | ||||
68 | if (iconItem.width <= units.iconSizes.large) { | ||||
69 | return units.iconSizes.small | ||||
70 | } | ||||
71 | if (iconItem.width <= 96) { | ||||
72 | return units.iconSizes.smallMedium | ||||
73 | } | ||||
74 | if (iconItem.width < 256) { | ||||
75 | return units.iconSizes.medium | ||||
76 | } | ||||
Most of these numbers correspond to standard icon sizes (e.g. units.iconSize.smallMedium == 22); maybe use those where possible ngraham: Most of these numbers correspond to standard icon sizes (e.g. `units.iconSize.smallMedium` ==… | |||||
Good to know! That was a straight copy from https://cgit.kde.org/kiconthemes.git/tree/src/kiconloader.cpp#n478 :D davidre: Good to know! That was a straight copy from https://cgit.kde.org/kiconthemes. | |||||
StatusNotifierItemSource::overlayIcon() also has some sizes hard coded. I quickly checked, looks like the values are the same. if (iconItem.width <= units.iconSize.medium) { return units.iconSize.small / 2; } if (iconItem.width <= units.iconSize.large) { return units.iconSize.small; } kmaterka: [[ https://phabricator.kde.org/source/plasma… | |||||
77 | return units.iconSizes.large; | ||||
78 | } | ||||
79 | height: width | ||||
80 | anchors { | ||||
81 | right: iconItem.right | ||||
82 | bottom: iconItem.bottom | ||||
ngraham: always round when multiplying by a non-integer value | |||||
In StatusNotifierItemSource::overlayIcon() it has a different logic to position overlay. Margin is always the size of overlay icon. Another pre-existing inconsistency. Which one to choose? I think that KIconLoader is more important. kmaterka: In [[ https://phabricator.kde.org/source/plasma… | |||||
Hmm to me it looks it doesn't even have an margin. Or am I reading p.drawPixmap(QRect(m_iconPixmap.width()-size, m_iconPixmap.height()-size, size, size), overlay->pixmap(size, size), QRect(0,0,size,size)); wrong? davidre: Hmm to me it looks it doesn't even have an margin. Or am I reading ` p.drawPixmap(QRect… | |||||
Yes, you are correct, my mistake. So StatusNotifierItemSource has no margin and KIconLoader has 5% of icon size - another inconsistency. kmaterka: Yes, you are correct, my mistake. So `StatusNotifierItemSource` has no margin and `KIconLoader`… | |||||
Yes, when you have a positional value that isn't an integer, the engine can end up positioning the item on half-pixels and everything looks blurry. ngraham: Yes, when you have a positional value that isn't an integer, the engine can end up positioning… | |||||
The 0.05 * iconSize in KIconLoader has an implicit math.floor by the int conversion. bruns: The `0.05 * iconSize` in KIconLoader has an implicit `math.floor` by the int conversion. | |||||
83 | bottomMargin: Math.floor(0.05 * iconItem.width) | ||||
84 | rightMargin: anchors.bottomMargin | ||||
85 | } | ||||
86 | } | ||||
50 | 87 | | |||
51 | onContextMenu: { | 88 | onContextMenu: { | ||
52 | openContextMenu(plasmoid.nativeInterface.popupPosition(taskIcon, mouse.x, mouse.y)) | 89 | openContextMenu(plasmoid.nativeInterface.popupPosition(taskIcon, mouse.x, mouse.y)) | ||
53 | } | 90 | } | ||
54 | 91 | | |||
55 | onClicked: { | 92 | onClicked: { | ||
56 | var pos = plasmoid.nativeInterface.popupPosition(taskIcon, mouse.x, mouse.y); | 93 | var pos = plasmoid.nativeInterface.popupPosition(taskIcon, mouse.x, mouse.y); | ||
57 | 94 | | |||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |
You need to change here as well.