Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/package/contents/ui/ItemGridView.qml
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 120 | onDragMove: { | |||
---|---|---|---|---|---|
126 | var cPos = mapToItem(gridView.contentItem, x, event.y); | 126 | var cPos = mapToItem(gridView.contentItem, x, event.y); | ||
127 | var item = gridView.itemAt(cPos.x, cPos.y); | 127 | var item = gridView.itemAt(cPos.x, cPos.y); | ||
128 | 128 | | |||
129 | if (item) { | 129 | if (item) { | ||
130 | if (kicker.dragSource.parent === gridView.contentItem) { | 130 | if (kicker.dragSource.parent === gridView.contentItem) { | ||
131 | if (item !== kicker.dragSource) { | 131 | if (item !== kicker.dragSource) { | ||
132 | item.GridView.view.model.moveRow(dragSource.itemIndex, item.itemIndex); | 132 | item.GridView.view.model.moveRow(dragSource.itemIndex, item.itemIndex); | ||
133 | } | 133 | } | ||
134 | } else if (kicker.dragSource.view.model.favoritesModel === model | 134 | } else if (kicker.dragSource.GridView.view.model.favoritesModel === model | ||
135 | && !model.isFavorite(kicker.dragSource.favoriteId)) { | 135 | && !model.isFavorite(kicker.dragSource.favoriteId)) { | ||
136 | var hasPlaceholder = (model.dropPlaceholderIndex !== -1); | 136 | var hasPlaceholder = (model.dropPlaceholderIndex !== -1); | ||
137 | 137 | | |||
138 | model.dropPlaceholderIndex = item.itemIndex; | 138 | model.dropPlaceholderIndex = item.itemIndex; | ||
139 | 139 | | |||
140 | if (!hasPlaceholder) { | 140 | if (!hasPlaceholder) { | ||
141 | gridView.currentIndex = (item.itemIndex - 1); | 141 | gridView.currentIndex = (item.itemIndex - 1); | ||
142 | } | 142 | } | ||
143 | } | 143 | } | ||
144 | } else if (kicker.dragSource.parent !== gridView.contentItem | 144 | } else if (kicker.dragSource.parent !== gridView.contentItem | ||
145 | && kicker.dragSource.view.model.favoritesModel === model | 145 | && kicker.dragSource.GridView.view.model.favoritesModel === model | ||
146 | && !model.isFavorite(kicker.dragSource.favoriteId)) { | 146 | && !model.isFavorite(kicker.dragSource.favoriteId)) { | ||
147 | var hasPlaceholder = (model.dropPlaceholderIndex !== -1); | 147 | var hasPlaceholder = (model.dropPlaceholderIndex !== -1); | ||
148 | 148 | | |||
149 | model.dropPlaceholderIndex = hasPlaceholder ? model.count - 1 : model.count; | 149 | model.dropPlaceholderIndex = hasPlaceholder ? model.count - 1 : model.count; | ||
150 | 150 | | |||
151 | if (!hasPlaceholder) { | 151 | if (!hasPlaceholder) { | ||
152 | gridView.currentIndex = (model.count - 1); | 152 | gridView.currentIndex = (model.count - 1); | ||
153 | } | 153 | } | ||
154 | } else { | 154 | } else { | ||
155 | model.dropPlaceholderIndex = -1; | 155 | model.dropPlaceholderIndex = -1; | ||
156 | gridView.currentIndex = -1; | 156 | gridView.currentIndex = -1; | ||
157 | } | 157 | } | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | onDragLeave: { | 160 | onDragLeave: { | ||
161 | if ("dropPlaceholderIndex" in model) { | 161 | if ("dropPlaceholderIndex" in model) { | ||
162 | model.dropPlaceholderIndex = -1; | 162 | model.dropPlaceholderIndex = -1; | ||
163 | gridView.currentIndex = -1; | 163 | gridView.currentIndex = -1; | ||
164 | } | 164 | } | ||
165 | } | 165 | } | ||
166 | 166 | | |||
167 | onDrop: { | 167 | onDrop: { | ||
168 | if (kicker.dragSource && kicker.dragSource.parent !== gridView.contentItem && kicker.dragSource.view.model.favoritesModel === model) { | 168 | if (kicker.dragSource && kicker.dragSource.parent !== gridView.contentItem && kicker.dragSource.GridView.view.model.favoritesModel === model) { | ||
169 | model.addFavorite(kicker.dragSource.favoriteId, model.dropPlaceholderIndex); | 169 | model.addFavorite(kicker.dragSource.favoriteId, model.dropPlaceholderIndex); | ||
170 | gridView.currentIndex = -1; | 170 | gridView.currentIndex = -1; | ||
171 | } | 171 | } | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | Timer { | 174 | Timer { | ||
175 | id: resetAnimationDurationTimer | 175 | id: resetAnimationDurationTimer | ||
176 | 176 | | |||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Line(s) | 396 | if (mouse.button == Qt.RightButton) { | |||
405 | } | 405 | } | ||
406 | } else { | 406 | } else { | ||
407 | pressedItem = gridView.currentItem; | 407 | pressedItem = gridView.currentItem; | ||
408 | } | 408 | } | ||
409 | } | 409 | } | ||
410 | 410 | | |||
411 | onReleased: { | 411 | onReleased: { | ||
412 | mouse.accepted = true; | 412 | mouse.accepted = true; | ||
413 | updatePositionProperties(mouse.x, mouse.y); | ||||
413 | 414 | | |||
414 | if (gridView.currentItem && gridView.currentItem == pressedItem) { | 415 | if (pressedItem && gridView.currentItem == pressedItem) { | ||
415 | if ("trigger" in gridView.model) { | 416 | if ("trigger" in gridView.model) { | ||
416 | gridView.model.trigger(pressedItem.itemIndex, "", null); | 417 | gridView.model.trigger(pressedItem.itemIndex, "", null); | ||
417 | root.toggle(); | 418 | root.toggle(); | ||
418 | } | 419 | } | ||
419 | 420 | | |||
420 | itemGrid.itemActivated(pressedItem.itemIndex, "", null); | 421 | itemGrid.itemActivated(pressedItem.itemIndex, "", null); | ||
421 | } else if (!pressedItem && mouse.button == Qt.LeftButton) { | 422 | } else if (pressX != -1 && mouse.button == Qt.LeftButton) { | ||
422 | root.toggle(); | 423 | root.toggle(); | ||
423 | } | 424 | } | ||
424 | 425 | | |||
425 | pressX = -1; | 426 | pressX = -1; | ||
426 | pressY = -1; | 427 | pressY = -1; | ||
427 | pressedItem = null; | 428 | pressedItem = null; | ||
428 | } | 429 | } | ||
429 | 430 | | |||
430 | onPositionChanged: { | 431 | onPositionChanged: { | ||
431 | var item = updatePositionProperties(mouse.x, mouse.y); | 432 | var item = updatePositionProperties(mouse.x, mouse.y); | ||
432 | 433 | | |||
434 | if (pressedItem) { | ||||
435 | pressedItem = null; | ||||
436 | } | ||||
437 | | ||||
433 | if (gridView.currentIndex != -1) { | 438 | if (gridView.currentIndex != -1) { | ||
434 | if (dragEnabled && pressX != -1 && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { | 439 | if (dragEnabled && pressX != -1 && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { | ||
435 | if ("pluginName" in item.m) { | 440 | if ("pluginName" in item.m) { | ||
436 | dragHelper.startDrag(kicker, item.url, item.icon, | 441 | dragHelper.startDrag(kicker, item.url, item.icon, | ||
437 | "text/x-plasmoidservicename", item.m.pluginName); | 442 | "text/x-plasmoidservicename", item.m.pluginName); | ||
438 | } else { | 443 | } else { | ||
439 | dragHelper.startDrag(kicker, item.url, item.icon); | 444 | dragHelper.startDrag(kicker, item.url, item.icon); | ||
440 | } | 445 | } | ||
441 | 446 | | |||
442 | kicker.dragSource = item; | 447 | kicker.dragSource = item; | ||
443 | | ||||
444 | pressX = -1; | | |||
445 | pressY = -1; | | |||
446 | } | 448 | } | ||
447 | } | 449 | } | ||
448 | } | 450 | } | ||
449 | 451 | | |||
450 | onContainsMouseChanged: { | 452 | onContainsMouseChanged: { | ||
451 | if (!containsMouse) { | 453 | if (!containsMouse) { | ||
452 | if (!actionMenu.opened) { | 454 | if (!actionMenu.opened) { | ||
453 | gridView.currentIndex = -1; | 455 | gridView.currentIndex = -1; | ||
Show All 12 Lines |