Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/package/contents/ui/ItemListDelegate.qml
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 27 | Item { | |||
---|---|---|---|---|---|
48 | 48 | | |||
49 | onHasChildrenChanged: { | 49 | onHasChildrenChanged: { | ||
50 | if (!hasChildren && ListView.view.currentItem === item) { | 50 | if (!hasChildren && ListView.view.currentItem === item) { | ||
51 | ListView.view.currentIndex = -1; | 51 | ListView.view.currentIndex = -1; | ||
52 | } | 52 | } | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | onAboutToShowActionMenu: { | 55 | onAboutToShowActionMenu: { | ||
56 | var actionList = hasActionList ? model.actionList : []; | 56 | var actionList = item.hasActionList ? model.actionList : []; | ||
57 | Tools.fillActionMenu(i18n, actionMenu, actionList, ListView.view.model.favoritesModel, model.favoriteId); | 57 | Tools.fillActionMenu(i18n, actionMenu, actionList, ListView.view.model.favoritesModel, model.favoriteId); | ||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | onActionTriggered: { | 60 | onActionTriggered: { | ||
61 | if (Tools.triggerAction(ListView.view.model, model.index, actionId, actionArgument) === true) { | 61 | if (Tools.triggerAction(ListView.view.model, model.index, actionId, actionArgument) === true) { | ||
62 | plasmoid.expanded = false; | 62 | plasmoid.expanded = false; | ||
63 | } | 63 | } | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | function openActionMenu(visualParent, x, y) { | 66 | function openActionMenu(visualParent, x, y) { | ||
67 | aboutToShowActionMenu(actionMenu); | 67 | aboutToShowActionMenu(actionMenu); | ||
68 | actionMenu.visualParent = visualParent; | 68 | actionMenu.visualParent = visualParent; | ||
69 | actionMenu.open(x, y); | 69 | actionMenu.open(x, y); | ||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | ActionMenu { | 72 | ActionMenu { | ||
73 | id: actionMenu | 73 | id: actionMenu | ||
74 | 74 | | |||
75 | onActionClicked: { | 75 | onActionClicked: { | ||
76 | actionTriggered(actionId, actionArgument); | 76 | item.actionTriggered(actionId, actionArgument); | ||
77 | } | 77 | } | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | MouseArea { | 80 | MouseArea { | ||
81 | id: mouseArea | 81 | id: mouseArea | ||
82 | 82 | | |||
83 | anchors { | 83 | anchors { | ||
84 | left: parent.left | 84 | left: parent.left | ||
85 | right: parent.right | 85 | right: parent.right | ||
86 | verticalCenter: parent.verticalCenter | 86 | verticalCenter: parent.verticalCenter | ||
87 | } | 87 | } | ||
88 | 88 | | |||
89 | height: parent.height | 89 | height: parent.height | ||
90 | 90 | | |||
91 | property int mouseCol | 91 | property int mouseCol | ||
92 | property bool pressed: false | 92 | property bool pressed: false | ||
93 | property int pressX: -1 | 93 | property int pressX: -1 | ||
94 | property int pressY: -1 | 94 | property int pressY: -1 | ||
95 | 95 | | |||
96 | hoverEnabled: true | 96 | hoverEnabled: true | ||
97 | acceptedButtons: Qt.LeftButton | Qt.RightButton | 97 | acceptedButtons: Qt.LeftButton | Qt.RightButton | ||
98 | 98 | | |||
99 | onPressed: { | 99 | onPressed: { | ||
100 | if (mouse.buttons & Qt.RightButton) { | 100 | if (mouse.buttons & Qt.RightButton) { | ||
101 | if (hasActionList) { | 101 | if (item.hasActionList) { | ||
102 | openActionMenu(mouseArea, mouse.x, mouse.y); | 102 | item.openActionMenu(mouseArea, mouse.x, mouse.y); | ||
103 | } | 103 | } | ||
104 | } else { | 104 | } else { | ||
105 | pressed = true; | 105 | pressed = true; | ||
106 | pressX = mouse.x; | 106 | pressX = mouse.x; | ||
107 | pressY = mouse.y; | 107 | pressY = mouse.y; | ||
108 | } | 108 | } | ||
109 | } | 109 | } | ||
110 | 110 | | |||
111 | onReleased: { | 111 | onReleased: { | ||
112 | if (pressed && !hasChildren) { | 112 | if (pressed && !item.hasChildren) { | ||
113 | item.ListView.view.model.trigger(index, "", null); | 113 | item.ListView.view.model.trigger(index, "", null); | ||
114 | plasmoid.expanded = false; | 114 | plasmoid.expanded = false; | ||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | pressed = false; | 117 | pressed = false; | ||
118 | pressX = -1; | 118 | pressX = -1; | ||
119 | pressY = -1; | 119 | pressY = -1; | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | onPositionChanged: { | 122 | onPositionChanged: { | ||
123 | if (pressX != -1 && model.url && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { | 123 | if (pressX != -1 && model.url && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { | ||
124 | dragHelper.startDrag(kicker, model.url, model.decoration); | 124 | dragHelper.startDrag(kicker, model.url, model.decoration); | ||
125 | pressed = false; | 125 | pressed = false; | ||
126 | pressX = -1; | 126 | pressX = -1; | ||
127 | pressY = -1; | 127 | pressY = -1; | ||
128 | 128 | | |||
129 | return; | 129 | return; | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | // FIXME: Correct escape angle calc for right screen edge. | 132 | // FIXME: Correct escape angle calc for right screen edge. | ||
133 | if (justOpenedTimer.running || !hasChildren) { | 133 | if (justOpenedTimer.running || !item.hasChildren) { | ||
134 | item.ListView.view.currentIndex = index; | 134 | item.ListView.view.currentIndex = index; | ||
135 | } else { | 135 | } else { | ||
136 | mouseCol = mouse.x; | 136 | mouseCol = mouse.x; | ||
137 | 137 | | |||
138 | if (index === item.ListView.view.currentIndex) { | 138 | if (index === item.ListView.view.currentIndex) { | ||
139 | updateCurrentItem(); | 139 | updateCurrentItem(); | ||
140 | } else if ((index == item.ListView.view.currentIndex - 1) && mouse.y < (itemHeight - 6) | 140 | } else if ((index == item.ListView.view.currentIndex - 1) && mouse.y < (itemHeight - 6) | ||
141 | || (index == item.ListView.view.currentIndex + 1) && mouse.y > 5) { | 141 | || (index == item.ListView.view.currentIndex + 1) && mouse.y > 5) { | ||
142 | 142 | | |||
143 | if ((childDialog != null && childDialog.facingLeft) | 143 | if ((item.childDialog != null && item.childDialog.facingLeft) | ||
144 | ? mouse.x > item.ListView.view.eligibleWidth - 5 : mouse.x < item.ListView.view.eligibleWidth + 5) { | 144 | ? mouse.x > item.ListView.view.eligibleWidth - 5 : mouse.x < item.ListView.view.eligibleWidth + 5) { | ||
145 | updateCurrentItem(); | 145 | updateCurrentItem(); | ||
146 | } | 146 | } | ||
147 | } else if ((childDialog != null && childDialog.facingLeft) | 147 | } else if ((item.childDialog != null && item.childDialog.facingLeft) | ||
148 | ? mouse.x > item.ListView.view.eligibleWidth : mouse.x < item.ListView.view.eligibleWidth) { | 148 | ? mouse.x > item.ListView.view.eligibleWidth : mouse.x < item.ListView.view.eligibleWidth) { | ||
149 | updateCurrentItem(); | 149 | updateCurrentItem(); | ||
150 | } | 150 | } | ||
151 | 151 | | |||
152 | updateCurrentItemTimer.start(); | 152 | updateCurrentItemTimer.start(); | ||
153 | } | 153 | } | ||
154 | } | 154 | } | ||
155 | 155 | | |||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 195 | PlasmaCore.IconItem { | |||
206 | usesPlasmaTheme: false | 206 | usesPlasmaTheme: false | ||
207 | 207 | | |||
208 | source: model.decoration | 208 | source: model.decoration | ||
209 | } | 209 | } | ||
210 | 210 | | |||
211 | PlasmaComponents.Label { | 211 | PlasmaComponents.Label { | ||
212 | id: label | 212 | id: label | ||
213 | 213 | | |||
214 | enabled: !isParent || (isParent && hasChildren) | 214 | enabled: !isParent || (isParent && item.hasChildren) | ||
215 | 215 | | |||
216 | anchors.verticalCenter: parent.verticalCenter | 216 | anchors.verticalCenter: parent.verticalCenter | ||
217 | 217 | | |||
218 | width: parent.width - icon.width - arrow.width - parent.actualSpacing | 218 | width: parent.width - icon.width - arrow.width - parent.actualSpacing | ||
219 | 219 | | |||
220 | verticalAlignment: Text.AlignVCenter | 220 | verticalAlignment: Text.AlignVCenter | ||
221 | 221 | | |||
222 | textFormat: Text.PlainText | 222 | textFormat: Text.PlainText | ||
223 | wrapMode: Text.NoWrap | 223 | wrapMode: Text.NoWrap | ||
224 | elide: Text.ElideRight | 224 | elide: Text.ElideRight | ||
225 | 225 | | |||
226 | text: model.display | 226 | text: model.display | ||
227 | } | 227 | } | ||
228 | 228 | | |||
229 | PlasmaCore.SvgItem { | 229 | PlasmaCore.SvgItem { | ||
230 | id: arrow | 230 | id: arrow | ||
231 | 231 | | |||
232 | anchors.verticalCenter: parent.verticalCenter | 232 | anchors.verticalCenter: parent.verticalCenter | ||
233 | 233 | | |||
234 | width: visible ? units.iconSizes.small : 0 | 234 | width: visible ? units.iconSizes.small : 0 | ||
235 | height: width | 235 | height: width | ||
236 | 236 | | |||
237 | visible: hasChildren | 237 | visible: item.hasChildren | ||
238 | opacity: (item.ListView.view.currentIndex === index) ? 1.0 : 0.4 | 238 | opacity: (item.ListView.view.currentIndex === index) ? 1.0 : 0.4 | ||
239 | 239 | | |||
240 | svg: arrows | 240 | svg: arrows | ||
241 | elementId: (Qt.application.layoutDirection == Qt.RightToLeft) ? "left-arrow" : "right-arrow" | 241 | elementId: (Qt.application.layoutDirection == Qt.RightToLeft) ? "left-arrow" : "right-arrow" | ||
242 | } | 242 | } | ||
243 | } | 243 | } | ||
244 | 244 | | |||
245 | Component { | 245 | Component { | ||
Show All 12 Lines | 257 | Loader { | |||
258 | id: separatorLoader | 258 | id: separatorLoader | ||
259 | 259 | | |||
260 | anchors.left: parent.left | 260 | anchors.left: parent.left | ||
261 | anchors.leftMargin: highlightItemSvg.margins.left | 261 | anchors.leftMargin: highlightItemSvg.margins.left | ||
262 | anchors.right: parent.right | 262 | anchors.right: parent.right | ||
263 | anchors.rightMargin: highlightItemSvg.margins.right | 263 | anchors.rightMargin: highlightItemSvg.margins.right | ||
264 | anchors.verticalCenter: parent.verticalCenter | 264 | anchors.verticalCenter: parent.verticalCenter | ||
265 | 265 | | |||
266 | active: isSeparator | 266 | active: item.isSeparator | ||
267 | 267 | | |||
268 | asynchronous: false | 268 | asynchronous: false | ||
269 | sourceComponent: separatorComponent | 269 | sourceComponent: separatorComponent | ||
270 | } | 270 | } | ||
271 | 271 | | |||
272 | Keys.onPressed: { | 272 | Keys.onPressed: { | ||
273 | if (event.key === Qt.Key_Menu && hasActionList) { | 273 | if (event.key === Qt.Key_Menu && item.hasActionList) { | ||
274 | event.accepted = true; | 274 | event.accepted = true; | ||
275 | openActionMenu(mouseArea); | 275 | item.openActionMenu(mouseArea); | ||
276 | } else if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return) && !hasChildren) { | 276 | } else if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return) && !item.hasChildren) { | ||
277 | if (!hasChildren) { | 277 | if (!item.hasChildren) { | ||
278 | event.accepted = true; | 278 | event.accepted = true; | ||
279 | item.ListView.view.model.trigger(index, "", null); | 279 | item.ListView.view.model.trigger(index, "", null); | ||
280 | plasmoid.expanded = false; | 280 | plasmoid.expanded = false; | ||
281 | } | 281 | } | ||
282 | } | 282 | } | ||
283 | } | 283 | } | ||
284 | } | 284 | } |