Changeset View
Changeset View
Standalone View
Standalone View
applets/kimpanel/package/contents/ui/CompactRepresentation.qml
- This file was copied from applets/kimpanel/package/contents/ui/main.qml.
Show All 22 Lines | |||||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | 23 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
24 | import org.kde.kquickcontrolsaddons 2.0 | 24 | import org.kde.kquickcontrolsaddons 2.0 | ||
25 | 25 | | |||
26 | Item { | 26 | Item { | ||
27 | id: kimpanel | 27 | id: kimpanel | ||
28 | property int visibleButtons: 0 | 28 | property int visibleButtons: 0 | ||
29 | 29 | | |||
30 | property bool vertical: plasmoid.formFactor == PlasmaCore.Types.Vertical | 30 | property bool vertical: plasmoid.formFactor == PlasmaCore.Types.Vertical | ||
31 | property PlasmaCore.DataSource dataEngine | ||||
31 | 32 | | |||
32 | LayoutMirroring.enabled: !vertical && Qt.application.layoutDirection === Qt.RightToLeft | 33 | LayoutMirroring.enabled: !vertical && Qt.application.layoutDirection === Qt.RightToLeft | ||
33 | LayoutMirroring.childrenInherit: true | 34 | LayoutMirroring.childrenInherit: true | ||
34 | 35 | | |||
35 | Layout.minimumWidth: vertical ? units.iconSizes.small : items.implicitWidth | 36 | Layout.minimumWidth: vertical ? units.iconSizes.small : items.implicitWidth | ||
36 | Layout.minimumHeight: !vertical ? units.iconSizes.small : items.implicitHeight | 37 | Layout.minimumHeight: !vertical ? units.iconSizes.small : items.implicitHeight | ||
37 | Layout.preferredHeight: Layout.minimumHeight | 38 | Layout.preferredHeight: Layout.minimumHeight | ||
38 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | | |||
39 | 39 | | |||
40 | InputPanel { } | 40 | InputPanel { } | ||
41 | 41 | | |||
42 | Flow { | 42 | Flow { | ||
43 | id: items | 43 | id: items | ||
44 | width: parent.width | 44 | width: parent.width | ||
45 | height: parent.height | 45 | height: parent.height | ||
46 | x: (parent.width - childrenRect.width) / 2 | 46 | x: (parent.width - childrenRect.width) / 2 | ||
47 | y: (parent.height - childrenRect.height) / 2 | 47 | y: (parent.height - childrenRect.height) / 2 | ||
48 | flow: kimpanel.vertical ? Flow.LeftToRight : Flow.TopToBottom | 48 | flow: kimpanel.vertical ? Flow.LeftToRight : Flow.TopToBottom | ||
49 | 49 | | |||
50 | property int iconSize: Math.min(units.iconSizeHints.panel, units.roundToIconSize(Math.min(width, height))) | 50 | property int iconSize: Math.min(units.iconSizeHints.panel, units.roundToIconSize(Math.min(width, height))) | ||
51 | 51 | | |||
52 | Item { | ||||
53 | width: items.iconSize | ||||
54 | height: items.iconSize | ||||
55 | StatusIcon { | ||||
56 | id: firstStatusIcon | ||||
57 | anchors.centerIn: parent | ||||
58 | width: items.iconSize | ||||
59 | height: items.iconSize | ||||
60 | label: dataEngine.data["statusbar"]["CurrentTag"] | ||||
61 | icon: dataEngine.data["statusbar"]["CurrentIconName"] | ||||
62 | tip: "Currently Active Layout" | ||||
63 | | ||||
64 | onTriggered: { | ||||
65 | if (button == Qt.LeftButton) { | ||||
66 | plasmoid.expanded = !plasmoid.expanded; | ||||
67 | } | ||||
68 | else { | ||||
69 | mainContextMenu.openRelative(); | ||||
70 | } | ||||
71 | } | ||||
72 | } | ||||
73 | } | ||||
74 | | ||||
52 | Repeater { | 75 | Repeater { | ||
53 | model: ListModel { | 76 | model: ListModel { | ||
54 | id: list | 77 | id: list | ||
55 | dynamicRoles: true | 78 | dynamicRoles: true | ||
56 | } | 79 | } | ||
57 | 80 | | |||
58 | delegate: Item { | 81 | delegate: Item { | ||
59 | id: iconDelegate | 82 | id: iconDelegate | ||
Show All 18 Lines | 100 | } else { | |||
78 | contextMenu.open(statusIcon, {key: model.key, label: model.label}); | 101 | contextMenu.open(statusIcon, {key: model.key, label: model.label}); | ||
79 | } | 102 | } | ||
80 | } | 103 | } | ||
81 | } | 104 | } | ||
82 | } | 105 | } | ||
83 | } | 106 | } | ||
84 | } | 107 | } | ||
85 | 108 | | |||
109 | Connections { | ||||
110 | target: dataEngine | ||||
111 | onDataChanged: { | ||||
112 | showMenu(actionMenu, dataEngine.data["statusbar"]["Menu"]); | ||||
113 | var data = dataEngine.data["statusbar"]["Properties"]; | ||||
114 | if (!data) { | ||||
115 | kimpanel.visibleButtons = 0; | ||||
116 | return; | ||||
117 | } | ||||
118 | | ||||
119 | timer.restart(); | ||||
120 | } | ||||
121 | } | ||||
122 | | ||||
86 | function clickHandler(key) { | 123 | function clickHandler(key) { | ||
87 | var service = dataEngine.serviceForSource("statusbar"); | 124 | var service = dataEngine.serviceForSource("statusbar"); | ||
88 | var operation = service.operationDescription("TriggerProperty"); | 125 | var operation = service.operationDescription("TriggerProperty"); | ||
89 | operation.key = key; | 126 | operation.key = key; | ||
90 | service.startOperationCall(operation); | 127 | service.startOperationCall(operation); | ||
91 | } | 128 | } | ||
92 | 129 | | |||
93 | function action(key) { | 130 | function action(key) { | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 180 | onActionClicked: { | |||
144 | clickHandler(actionId); | 181 | clickHandler(actionId); | ||
145 | } | 182 | } | ||
146 | } | 183 | } | ||
147 | 184 | | |||
148 | ContextMenu { | 185 | ContextMenu { | ||
149 | id: contextMenu | 186 | id: contextMenu | ||
150 | } | 187 | } | ||
151 | 188 | | |||
189 | MainContextMenu { | ||||
190 | id: mainContextMenu | ||||
191 | | ||||
192 | onConfigureClicked: { | ||||
193 | dataSource.data["statusbar"]["LayoutModels"].openConfigDialog(); | ||||
194 | } | ||||
195 | } | ||||
196 | | ||||
152 | Timer { | 197 | Timer { | ||
153 | id: timer | 198 | id: timer | ||
154 | interval: 50 | 199 | interval: 50 | ||
155 | onTriggered: { | 200 | onTriggered: { | ||
156 | var data = dataEngine.data["statusbar"]["Properties"]; | 201 | var data = dataEngine.data["statusbar"]["Properties"]; | ||
157 | if (!data) { | 202 | if (!data) { | ||
158 | return; | 203 | return; | ||
159 | } | 204 | } | ||
Show All 29 Lines | 223 | for (i = 0; i < data.length; i ++) { | |||
189 | } else { | 234 | } else { | ||
190 | list.append(itemData); | 235 | list.append(itemData); | ||
191 | } | 236 | } | ||
192 | c = c + 1; | 237 | c = c + 1; | ||
193 | } | 238 | } | ||
194 | contextMenu.actionList = hiddenActions; | 239 | contextMenu.actionList = hiddenActions; | ||
195 | } | 240 | } | ||
196 | } | 241 | } | ||
197 | | ||||
198 | PlasmaCore.DataSource { | | |||
199 | id: dataEngine | | |||
200 | engine: "kimpanel" | | |||
201 | connectedSources: ["statusbar"] | | |||
202 | onDataChanged: { | | |||
203 | showMenu(actionMenu, dataEngine.data["statusbar"]["Menu"]); | | |||
204 | var data = dataEngine.data["statusbar"]["Properties"]; | | |||
205 | if (!data) { | | |||
206 | kimpanel.visibleButtons = 0; | | |||
207 | return; | | |||
208 | } | | |||
209 | | ||||
210 | timer.restart(); | | |||
211 | } | | |||
212 | } | | |||
213 | } | 242 | } | ||
214 | 243 | |