Changeset View
Changeset View
Standalone View
Standalone View
src/controls/private/ActionButton.qml
Show All 14 Lines | |||||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.1 | 20 | import QtQuick 2.1 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtGraphicalEffects 1.0 | 22 | import QtGraphicalEffects 1.0 | ||
23 | import org.kde.kirigami 1.0 | 23 | import org.kde.kirigami 2.0 | ||
24 | 24 | | |||
25 | import "../templates/private" | 25 | import "../templates/private" | ||
26 | 26 | | |||
27 | Item { | 27 | Item { | ||
28 | id: root | 28 | id: root | ||
29 | anchors { | 29 | anchors { | ||
30 | left: parent.left | 30 | left: parent.left | ||
31 | right: parent.right | 31 | right: parent.right | ||
Show All 23 Lines | 49 | Item { | |||
55 | } | 55 | } | ||
56 | implicitWidth: implicitHeight + Units.iconSizes.smallMedium*3 | 56 | implicitWidth: implicitHeight + Units.iconSizes.smallMedium*3 | ||
57 | implicitHeight: Units.iconSizes.large + Units.largeSpacing | 57 | implicitHeight: Units.iconSizes.large + Units.largeSpacing | ||
58 | 58 | | |||
59 | 59 | | |||
60 | onXChanged: { | 60 | onXChanged: { | ||
61 | if (mouseArea.pressed || edgeMouseArea.pressed || fakeContextMenuButton.pressed) { | 61 | if (mouseArea.pressed || edgeMouseArea.pressed || fakeContextMenuButton.pressed) { | ||
62 | if (globalDrawer && globalDrawer.enabled && globalDrawer.modal) { | 62 | if (globalDrawer && globalDrawer.enabled && globalDrawer.modal) { | ||
63 | globalDrawer.peeking = true; | ||||
64 | globalDrawer.visible = true; | ||||
63 | globalDrawer.position = Math.min(1, Math.max(0, (x - root.width/2 + button.width/2)/globalDrawer.contentItem.width + mouseArea.drawerShowAdjust)); | 65 | globalDrawer.position = Math.min(1, Math.max(0, (x - root.width/2 + button.width/2)/globalDrawer.contentItem.width + mouseArea.drawerShowAdjust)); | ||
64 | } | 66 | } | ||
65 | if (contextDrawer && contextDrawer.enabled && contextDrawer.modal) { | 67 | if (contextDrawer && contextDrawer.enabled && contextDrawer.modal) { | ||
68 | contextDrawer.peeking = true; | ||||
69 | contextDrawer.visible = true; | ||||
66 | contextDrawer.position = Math.min(1, Math.max(0, (root.width/2 - button.width/2 - x)/contextDrawer.contentItem.width + mouseArea.drawerShowAdjust)); | 70 | contextDrawer.position = Math.min(1, Math.max(0, (root.width/2 - button.width/2 - x)/contextDrawer.contentItem.width + mouseArea.drawerShowAdjust)); | ||
67 | } | 71 | } | ||
68 | } | 72 | } | ||
69 | } | 73 | } | ||
70 | 74 | | |||
71 | MouseArea { | 75 | MouseArea { | ||
72 | id: mouseArea | 76 | id: mouseArea | ||
73 | anchors.fill: parent | 77 | anchors.fill: parent | ||
Show All 38 Lines | 108 | onPressed: { | |||
112 | startX = button.x + button.width/2; | 116 | startX = button.x + button.width/2; | ||
113 | startMouseY = mouse.y; | 117 | startMouseY = mouse.y; | ||
114 | drawerShowAdjust = 0; | 118 | drawerShowAdjust = 0; | ||
115 | buttonPressedUnderMouse = mouse.x > buttonGraphics.x && mouse.x < buttonGraphics.x + buttonGraphics.width; | 119 | buttonPressedUnderMouse = mouse.x > buttonGraphics.x && mouse.x < buttonGraphics.x + buttonGraphics.width; | ||
116 | leftButtonPressedUnderMouse = !buttonPressedUnderMouse && leftAction && mouse.x < buttonGraphics.x; | 120 | leftButtonPressedUnderMouse = !buttonPressedUnderMouse && leftAction && mouse.x < buttonGraphics.x; | ||
117 | rightButtonPressedUnderMouse = !buttonPressedUnderMouse && rightAction && mouse.x > buttonGraphics.x + buttonGraphics.width; | 121 | rightButtonPressedUnderMouse = !buttonPressedUnderMouse && rightAction && mouse.x > buttonGraphics.x + buttonGraphics.width; | ||
118 | } | 122 | } | ||
119 | onReleased: { | 123 | onReleased: { | ||
124 | globalDrawer.peeking = false; | ||||
125 | contextDrawer.peeking = false; | ||||
120 | //pixel/second | 126 | //pixel/second | ||
121 | var x = button.x + button.width/2; | 127 | var x = button.x + button.width/2; | ||
122 | var speed = ((x - startX) / ((new Date()).getTime() - downTimestamp) * 1000); | 128 | var speed = ((x - startX) / ((new Date()).getTime() - downTimestamp) * 1000); | ||
123 | drawerShowAdjust = 0; | 129 | drawerShowAdjust = 0; | ||
124 | 130 | | |||
125 | //project where it would be a full second in the future | 131 | //project where it would be a full second in the future | ||
126 | if (globalDrawer && globalDrawer.modal && x + speed > Math.min(root.width/4*3, root.width/2 + globalDrawer.contentItem.width/2)) { | 132 | if (globalDrawer && globalDrawer.modal && x + speed > Math.min(root.width/4*3, root.width/2 + globalDrawer.contentItem.width/2)) { | ||
127 | globalDrawer.open(); | 133 | globalDrawer.open(); | ||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | 329 | MouseArea { | |||
373 | ContextIcon { | 379 | ContextIcon { | ||
374 | anchors.centerIn: parent | 380 | anchors.centerIn: parent | ||
375 | width: height | 381 | width: height | ||
376 | height: Units.iconSizes.smallMedium - Units.smallSpacing * 2 | 382 | height: Units.iconSizes.smallMedium - Units.smallSpacing * 2 | ||
377 | } | 383 | } | ||
378 | 384 | | |||
379 | onPressed: mouseArea.onPressed(mouse) | 385 | onPressed: mouseArea.onPressed(mouse) | ||
380 | onReleased: { | 386 | onReleased: { | ||
387 | globalDrawer.peeking = false; | ||||
388 | contextDrawer.peeking = false; | ||||
381 | var pos = root.mapFromItem(fakeContextMenuButton, mouse.x, mouse.y); | 389 | var pos = root.mapFromItem(fakeContextMenuButton, mouse.x, mouse.y); | ||
382 | if (pos.x < root.width/2 || (!contextDrawer.opened && mouse.x > 0 && mouse.x < width)) { | 390 | if (pos.x < root.width/2 || (!contextDrawer.drawerOpen && mouse.x > 0 && mouse.x < width)) { | ||
383 | contextDrawer.open(); | 391 | contextDrawer.open(); | ||
384 | } else if (contextDrawer.opened && mouse.x > 0 && mouse.x < width) { | 392 | } else if (contextDrawer.drawerOpen && mouse.x > 0 && mouse.x < width) { | ||
385 | contextDrawer.close(); | 393 | contextDrawer.close(); | ||
386 | } | 394 | } | ||
387 | if (globalDrawer.position > 0.5) { | 395 | if (globalDrawer.position > 0.5) { | ||
388 | globalDrawer.open(); | 396 | globalDrawer.open(); | ||
389 | } else { | 397 | } else { | ||
390 | globalDrawer.close(); | 398 | globalDrawer.close(); | ||
391 | } | 399 | } | ||
392 | } | 400 | } | ||
Show All 24 Lines |