Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/package/contents/ui/items/AbstractItem.qml
Show All 18 Lines | |||||
19 | 19 | | |||
20 | import QtQuick 2.2 | 20 | import QtQuick 2.2 | ||
21 | import org.kde.plasma.core 2.0 as PlasmaCore | 21 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
22 | import org.kde.plasma.components 2.0 as PlasmaComponents | 22 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
23 | 23 | | |||
24 | PlasmaCore.ToolTipArea { | 24 | PlasmaCore.ToolTipArea { | ||
25 | id: abstractItem | 25 | id: abstractItem | ||
26 | 26 | | |||
27 | height: effectiveItemSize + marginHints.top + marginHints.bottom | 27 | height: inVisibleLayout ? visibleLayout.iconSize : hiddenLayout.iconItemHeight | ||
28 | width: labelVisible ? parent.width : effectiveItemSize + marginHints.left + marginHints.right | 28 | width: inVisibleLayout ? visibleLayout.iconSize : hiddenLayout.width | ||
29 | 29 | | |||
30 | property real effectiveItemSize: hidden ? root.hiddenItemSize : root.itemSize | | |||
31 | property string itemId | 30 | property string itemId | ||
32 | property string category | 31 | property string category | ||
33 | property alias text: label.text | 32 | property alias text: label.text | ||
34 | property bool hidden: parent.objectName == "hiddenTasksColumn" | | |||
35 | property QtObject marginHints: parent.marginHints | | |||
36 | property bool labelVisible: abstractItem.hidden && !root.activeApplet | | |||
37 | property Item iconItem | 33 | property Item iconItem | ||
38 | //PlasmaCore.Types.ItemStatus | 34 | property int /*PlasmaCore.Types.ItemStatus*/ status | ||
39 | property int status | 35 | readonly property bool inHiddenLayout: effectiveStatus === PlasmaCore.Types.PassiveStatus | ||
36 | readonly property bool inVisibleLayout: effectiveStatus === PlasmaCore.Types.ActiveStatus | ||||
40 | property QtObject model | 37 | property QtObject model | ||
41 | 38 | | |||
42 | signal clicked(var mouse) | 39 | signal clicked(var mouse) | ||
43 | signal pressed(var mouse) | 40 | signal pressed(var mouse) | ||
44 | signal wheel(var wheel) | 41 | signal wheel(var wheel) | ||
45 | signal contextMenu(var mouse) | 42 | signal contextMenu(var mouse) | ||
46 | 43 | | |||
47 | property bool forcedHidden: plasmoid.configuration.hiddenItems.indexOf(itemId) !== -1 | 44 | property bool forcedHidden: plasmoid.configuration.hiddenItems.indexOf(itemId) !== -1 | ||
48 | property bool forcedShown: plasmoid.configuration.showAllItems || plasmoid.configuration.shownItems.indexOf(itemId) !== -1 | 45 | property bool forcedShown: plasmoid.configuration.showAllItems || plasmoid.configuration.shownItems.indexOf(itemId) !== -1 | ||
49 | 46 | | |||
50 | readonly property int effectiveStatus: { | 47 | readonly property int effectiveStatus: { | ||
51 | if (status === PlasmaCore.Types.HiddenStatus) { | 48 | if (status === PlasmaCore.Types.HiddenStatus) { | ||
52 | return PlasmaCore.Types.HiddenStatus | 49 | return PlasmaCore.Types.HiddenStatus | ||
53 | } else if (forcedShown || (!forcedHidden && status !== PlasmaCore.Types.PassiveStatus)) { | 50 | } else if (forcedShown || (!forcedHidden && status !== PlasmaCore.Types.PassiveStatus)) { | ||
54 | return PlasmaCore.Types.ActiveStatus | 51 | return PlasmaCore.Types.ActiveStatus | ||
55 | } else { | 52 | } else { | ||
56 | return PlasmaCore.Types.PassiveStatus | 53 | return PlasmaCore.Types.PassiveStatus | ||
57 | } | 54 | } | ||
58 | } | 55 | } | ||
59 | 56 | | |||
60 | /* subclasses need to assign to this tiiltip properties | 57 | /* subclasses need to assign to this tooltip properties | ||
61 | mainText: | 58 | mainText: | ||
62 | subText: | 59 | subText: | ||
63 | icon: | 60 | icon: | ||
64 | */ | 61 | */ | ||
65 | 62 | | |||
66 | location: { | 63 | location: { | ||
67 | if (abstractItem.parent && abstractItem.parent.objectName === "hiddenTasksColumn") { | 64 | if (inHiddenLayout) { | ||
68 | if (LayoutMirroring.enabled && plasmoid.location !== PlasmaCore.Types.RightEdge) { | 65 | if (LayoutMirroring.enabled && plasmoid.location !== PlasmaCore.Types.RightEdge) { | ||
69 | return PlasmaCore.Types.LeftEdge; | 66 | return PlasmaCore.Types.LeftEdge; | ||
70 | } else if (plasmoid.location !== PlasmaCore.Types.LeftEdge) { | 67 | } else if (plasmoid.location !== PlasmaCore.Types.LeftEdge) { | ||
71 | return PlasmaCore.Types.RightEdge; | 68 | return PlasmaCore.Types.RightEdge; | ||
72 | } | 69 | } | ||
73 | } | 70 | } | ||
74 | 71 | | |||
75 | return plasmoid.location; | 72 | return plasmoid.location; | ||
76 | } | 73 | } | ||
77 | 74 | | |||
78 | //BEGIN CONNECTIONS | 75 | //BEGIN CONNECTIONS | ||
79 | 76 | | |||
80 | property int creationId // used for item order tie breaking | 77 | property int creationId // used for item order tie breaking | ||
81 | onEffectiveStatusChanged: updateItemVisibility(abstractItem) | 78 | onEffectiveStatusChanged: updateItemVisibility(abstractItem) | ||
82 | onCategoryChanged: updateItemVisibility(abstractItem) | 79 | onCategoryChanged: updateItemVisibility(abstractItem) | ||
83 | onTextChanged: updateItemVisibility(abstractItem) | 80 | onTextChanged: updateItemVisibility(abstractItem) | ||
84 | Component.onCompleted: { | 81 | Component.onCompleted: { | ||
85 | creationId = root.creationIdCounter++ | 82 | creationId = root.creationIdCounter++ | ||
86 | updateItemVisibility(abstractItem) | 83 | updateItemVisibility(abstractItem) | ||
87 | } | 84 | } | ||
88 | 85 | | |||
89 | onContainsMouseChanged: { | 86 | onContainsMouseChanged: { | ||
90 | if (hidden && containsMouse) { | 87 | if (inHiddenLayout && containsMouse) { | ||
91 | root.hiddenLayout.hoveredItem = abstractItem | 88 | root.hiddenLayout.hoveredItem = abstractItem | ||
92 | } | 89 | } | ||
93 | } | 90 | } | ||
94 | 91 | | |||
95 | //END CONNECTIONS | 92 | //END CONNECTIONS | ||
96 | 93 | | |||
97 | PulseAnimation { | 94 | PulseAnimation { | ||
98 | targetItem: iconItem | 95 | targetItem: iconItem | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
149 | 146 | | |||
150 | PlasmaComponents.Label { | 147 | PlasmaComponents.Label { | ||
151 | id: label | 148 | id: label | ||
152 | anchors { | 149 | anchors { | ||
153 | left: parent.left | 150 | left: parent.left | ||
154 | leftMargin: iconItem ? iconItem.width + units.smallSpacing : 0 | 151 | leftMargin: iconItem ? iconItem.width + units.smallSpacing : 0 | ||
155 | verticalCenter: parent.verticalCenter | 152 | verticalCenter: parent.verticalCenter | ||
156 | } | 153 | } | ||
157 | opacity: labelVisible ? 1 : 0 | 154 | opacity: visible ? 1 : 0 | ||
158 | visible: abstractItem.hidden | 155 | visible: abstractItem.inHiddenLayout && !root.activeApplet | ||
159 | Behavior on opacity { | 156 | Behavior on opacity { | ||
160 | NumberAnimation { | 157 | NumberAnimation { | ||
161 | duration: units.longDuration | 158 | duration: units.longDuration | ||
162 | easing.type: Easing.InOutQuad | 159 | easing.type: Easing.InOutQuad | ||
163 | } | 160 | } | ||
164 | } | 161 | } | ||
165 | } | 162 | } | ||
166 | } | 163 | } | ||
167 | 164 | |