Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/MouseHandler.qml
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 60 | DropArea { | |||
---|---|---|---|---|---|
75 | 75 | | |||
76 | onDragMove: { | 76 | onDragMove: { | ||
77 | if (target.animating) { | 77 | if (target.animating) { | ||
78 | return; | 78 | return; | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | var above = target.childAt(event.x, event.y); | 81 | var above = target.childAt(event.x, event.y); | ||
82 | 82 | | |||
83 | if (!above) { | ||||
84 | hoveredItem = null; | ||||
85 | activationTimer.stop(); | ||||
86 | | ||||
87 | return; | ||||
88 | } | ||||
89 | | ||||
83 | // If we're mixing launcher tasks with other tasks and are moving | 90 | // If we're mixing launcher tasks with other tasks and are moving | ||
84 | // a (small) launcher task across a non-launcher task, don't allow | 91 | // a (small) launcher task across a non-launcher task, don't allow | ||
85 | // the latter to be the move target twice in a row for a while, as | 92 | // the latter to be the move target twice in a row for a while, as | ||
86 | // it will naturally be moved underneath the cursor as result of the | 93 | // it will naturally be moved underneath the cursor as result of the | ||
87 | // initial move, due to being far larger than the launcher delegate. | 94 | // initial move, due to being far larger than the launcher delegate. | ||
88 | // TODO: This restriction (minus the timer, which improves things) | 95 | // TODO: This restriction (minus the timer, which improves things) | ||
89 | // has been proven out in the EITM fork, but could be improved later | 96 | // has been proven out in the EITM fork, but could be improved later | ||
90 | // by tracking the cursor movement vector and allowing the drag if | 97 | // by tracking the cursor movement vector and allowing the drag if | ||
91 | // the movement direction has reversed, etablishing user intent to | 98 | // the movement direction has reversed, etablishing user intent to | ||
92 | // move back. | 99 | // move back. | ||
93 | if (!plasmoid.configuration.separateLaunchers && tasks.dragSource != null | 100 | if (!plasmoid.configuration.separateLaunchers && tasks.dragSource != null | ||
94 | && tasks.dragSource.m.IsLauncher === true && above != null | 101 | && tasks.dragSource.m.IsLauncher === true && above.m.IsLauncher !== true | ||
95 | && above.m.IsLauncher !== true && above == ignoredItem) { | 102 | && above == ignoredItem) { | ||
96 | return; | 103 | return; | ||
97 | } else { | 104 | } else { | ||
98 | ignoredItem = null; | 105 | ignoredItem = null; | ||
99 | } | 106 | } | ||
100 | 107 | | |||
101 | if (tasksModel.sortMode == TaskManager.TasksModel.SortManual && tasks.dragSource) { | 108 | if (tasksModel.sortMode == TaskManager.TasksModel.SortManual && tasks.dragSource) { | ||
102 | // Reject drags between different TaskList instances. | 109 | // Reject drags between different TaskList instances. | ||
103 | if (tasks.dragSource.parent != above.parent) { | 110 | if (tasks.dragSource.parent != above.parent) { | ||
104 | return; | 111 | return; | ||
105 | } | 112 | } | ||
106 | 113 | | |||
107 | var insertAt = TaskTools.insertIndexAt(above, event.x, event.y); | 114 | var insertAt = TaskTools.insertIndexAt(above, event.x, event.y); | ||
108 | 115 | | |||
109 | if (tasks.dragSource != above && tasks.dragSource.itemIndex != insertAt) { | 116 | if (tasks.dragSource != above && tasks.dragSource.itemIndex != insertAt) { | ||
110 | if (groupDialog.visible && groupDialog.visualParent) { | 117 | if (groupDialog.visible && groupDialog.visualParent) { | ||
111 | tasksModel.move(tasks.dragSource.itemIndex, insertAt, | 118 | tasksModel.move(tasks.dragSource.itemIndex, insertAt, | ||
112 | tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex)); | 119 | tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex)); | ||
113 | } else { | 120 | } else { | ||
114 | tasksModel.move(tasks.dragSource.itemIndex, insertAt); | 121 | tasksModel.move(tasks.dragSource.itemIndex, insertAt); | ||
115 | } | 122 | } | ||
116 | 123 | | |||
117 | ignoredItem = above; | 124 | ignoredItem = above; | ||
118 | ignoreItemTimer.restart(); | 125 | ignoreItemTimer.restart(); | ||
119 | } | 126 | } | ||
120 | } else if (!tasks.dragSource && above && hoveredItem != above) { | 127 | } else if (!tasks.dragSource && hoveredItem != above) { | ||
121 | hoveredItem = above; | 128 | hoveredItem = above; | ||
122 | activationTimer.restart(); | 129 | activationTimer.restart(); | ||
123 | } else if (!above) { | | |||
124 | hoveredItem = null; | | |||
125 | activationTimer.stop(); | | |||
126 | } | 130 | } | ||
127 | } | 131 | } | ||
128 | 132 | | |||
129 | onDragLeave: { | 133 | onDragLeave: { | ||
130 | hoveredItem = null; | 134 | hoveredItem = null; | ||
131 | activationTimer.stop(); | 135 | activationTimer.stop(); | ||
132 | } | 136 | } | ||
133 | 137 | | |||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |