Changeset View
Changeset View
Standalone View
Standalone View
applets/pager/package/contents/ui/main.qml
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 30 | MouseArea { | |||
---|---|---|---|---|---|
46 | Layout.fillWidth: root.vertical | 46 | Layout.fillWidth: root.vertical | ||
47 | Layout.fillHeight: !root.vertical | 47 | Layout.fillHeight: !root.vertical | ||
48 | 48 | | |||
49 | property bool dragging: false | 49 | property bool dragging: false | ||
50 | property int dragId | 50 | property int dragId | ||
51 | 51 | | |||
52 | property int dragSwitchDesktopId: -1 | 52 | property int dragSwitchDesktopId: -1 | ||
53 | 53 | | |||
54 | property int wheelDelta: 0 | ||||
55 | | ||||
54 | anchors.fill: parent | 56 | anchors.fill: parent | ||
55 | acceptedButtons: Qt.NoButton | 57 | acceptedButtons: Qt.NoButton | ||
56 | 58 | | |||
57 | hoverEnabled: true | 59 | hoverEnabled: true | ||
58 | 60 | | |||
59 | function colorWithAlpha(color, alpha) { | 61 | function colorWithAlpha(color, alpha) { | ||
60 | return Qt.rgba(color.r, color.g, color.b, alpha) | 62 | return Qt.rgba(color.r, color.g, color.b, alpha) | ||
61 | } | 63 | } | ||
Show All 33 Lines | 96 | onContainsMouseChanged: { | |||
95 | if (!containsMouse && dragging) { | 97 | if (!containsMouse && dragging) { | ||
96 | // Somewhat heavy-handed way to clean up after a window delegate drag | 98 | // Somewhat heavy-handed way to clean up after a window delegate drag | ||
97 | // exits the window. | 99 | // exits the window. | ||
98 | pagerModel.refresh(); | 100 | pagerModel.refresh(); | ||
99 | } | 101 | } | ||
100 | } | 102 | } | ||
101 | 103 | | |||
102 | onWheel: { | 104 | onWheel: { | ||
103 | if (wheel.angleDelta.y > 0 || wheel.angleDelta.x > 0) { | 105 | // Magic number 120 for common "one click, see: | ||
104 | pagerModel.changePage((repeater.count + pagerModel.currentPage - 2) % repeater.count); | 106 | // http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop | ||
107 | wheelDelta += wheel.angleDelta.y || wheel.angleDelta.x; | ||||
108 | | ||||
109 | var increment = 0; | ||||
110 | | ||||
111 | while (wheelDelta >= 120) { | ||||
112 | wheelDelta -= 120; | ||||
113 | increment++; | ||||
114 | } | ||||
115 | | ||||
116 | while (wheelDelta <= -120) { | ||||
117 | wheelDelta += 120; | ||||
118 | increment--; | ||||
119 | } | ||||
120 | | ||||
121 | while (increment != 0) { | ||||
122 | if (increment < 0) { | ||||
123 | pagerModel.changePage((pagerModel.currentPage + 1) % repeater.count); | ||||
105 | } else { | 124 | } else { | ||
106 | pagerModel.changePage(pagerModel.currentPage % repeater.count); | 125 | pagerModel.changePage((repeater.count + pagerModel.currentPage - 1) % repeater.count); | ||
126 | } | ||||
127 | | ||||
128 | increment += (increment < 0) ? 1 : -1; | ||||
107 | } | 129 | } | ||
108 | } | 130 | } | ||
109 | 131 | | |||
110 | PagerModel { | 132 | PagerModel { | ||
111 | id: pagerModel | 133 | id: pagerModel | ||
112 | 134 | | |||
113 | enabled: root.visible | 135 | enabled: root.visible | ||
114 | 136 | | |||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 194 | PlasmaCore.IconItem { | |||
182 | animated: false | 204 | animated: false | ||
183 | } | 205 | } | ||
184 | } | 206 | } | ||
185 | 207 | | |||
186 | Timer { | 208 | Timer { | ||
187 | id: dragTimer | 209 | id: dragTimer | ||
188 | interval: 1000 | 210 | interval: 1000 | ||
189 | onTriggered: { | 211 | onTriggered: { | ||
190 | if (dragSwitchDesktopId != -1 && dragSwitchDesktopId !== pagerModel.currentPage - 1) { | 212 | if (dragSwitchDesktopId != -1 && dragSwitchDesktopId !== pagerModel.currentPage) { | ||
191 | pagerModel.changePage(dragSwitchDesktopId); | 213 | pagerModel.changePage(dragSwitchDesktopId); | ||
192 | } | 214 | } | ||
193 | } | 215 | } | ||
194 | } | 216 | } | ||
195 | 217 | | |||
196 | Grid { | 218 | Grid { | ||
197 | id: pagerItemGrid | 219 | id: pagerItemGrid | ||
198 | 220 | | |||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
255 | Repeater { | 277 | Repeater { | ||
256 | id: repeater | 278 | id: repeater | ||
257 | model: pagerModel | 279 | model: pagerModel | ||
258 | 280 | | |||
259 | PlasmaCore.ToolTipArea { | 281 | PlasmaCore.ToolTipArea { | ||
260 | id: desktop | 282 | id: desktop | ||
261 | 283 | | |||
262 | property int desktopId: index | 284 | property int desktopId: index | ||
263 | property bool active: isActivityPager ? (index == pagerModel.currentPage) : (index + 1 == pagerModel.currentPage) | 285 | property bool active: (index == pagerModel.currentPage) | ||
264 | 286 | | |||
265 | mainText: model.display | 287 | mainText: model.display | ||
266 | // our ToolTip has maximumLineCount of 8 which doesn't fit but QML doesn't | 288 | // our ToolTip has maximumLineCount of 8 which doesn't fit but QML doesn't | ||
267 | // respect that in RichText so we effectively can put in as much as we like :) | 289 | // respect that in RichText so we effectively can put in as much as we like :) | ||
268 | // it also gives us more flexibility when it comes to styling the <li> | 290 | // it also gives us more flexibility when it comes to styling the <li> | ||
269 | textFormat: Text.RichText | 291 | textFormat: Text.RichText | ||
270 | 292 | | |||
271 | function updateSubText() { | 293 | function updateSubText() { | ||
▲ Show 20 Lines • Show All 230 Lines • Show Last 20 Lines |