Lomiri
Loading...
Searching...
No Matches
SideStage.qml
1/*
2 * Copyright (C) 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.15
18import QtQuick.Layouts 1.1
19import Lomiri.Components 1.3
20import Lomiri.Gestures 0.1
21import "../Components"
22
23Showable {
24 id: root
25 property bool showHint: true
26 property int panelWidth: units.gu(40)
27 readonly property alias dragging: hideSideStageDragArea.dragging
28 readonly property real progress: width / panelWidth
29 readonly property real handleWidth: units.gu(2)
30
31 width: 0
32 shown: false
33
34 Handle {
35 id: sideStageDragHandle
36
37 opacity: root.shown ? 1 : 0
38 Behavior on opacity { LomiriNumberAnimation {} }
39
40 anchors {
41 right: root.left
42 top: root.top
43 bottom: root.bottom
44 }
45 width: root.handleWidth
46 active: hideSideStageDragArea.pressed
47
48 Image {
49 z: -1
50 anchors.centerIn: parent
51 width: hideSideStageDragArea.pressed ? parent.width * 3 : parent.width * 2
52 height: parent.height
53 source: "graphics/sidestage_handle@20.png"
54 Behavior on width { LomiriNumberAnimation {} }
55 }
56 }
57
58 Rectangle {
59 anchors.fill: parent
60 color: Qt.rgba(0,0,0,0.95)
61 visible: showHint || hideAnimation.running
62 }
63
64 Column {
65 anchors.verticalCenter: parent.verticalCenter
66 width: panelWidth - units.gu(6)
67 x: panelWidth/2 - width/2
68 spacing: units.gu(3)
69 opacity: 0.8
70 visible: showHint && !hideAnimation.running
71
72 Icon {
73 width: units.gu(30)
74 anchors.horizontalCenter: parent.horizontalCenter
75 source: "graphics/sidestage_drag.svg"
76 color: enabled ? Qt.rgba(1,1,1,1) : Qt.rgba(1,0,0,1)
77 keyColor: Qt.rgba(1,1,1,1)
78 }
79
80 Label {
81 text: i18n.tr("Drag using 3 fingers any application from one window to the other")
82 width: parent.width
83 wrapMode: Text.WordWrap
84 color: enabled ? Qt.rgba(1,1,1,1) : Qt.rgba(1,0,0,1)
85 }
86 }
87
88 showAnimation: NumberAnimation {
89 property: "width"
90 to: panelWidth
91 duration: LomiriAnimation.BriskDuration
92 easing.type: Easing.OutCubic
93 }
94
95 hideAnimation: NumberAnimation {
96 property: "width"
97 to: 0
98 duration: LomiriAnimation.BriskDuration
99 easing.type: Easing.OutCubic
100 }
101
102 DragHandle {
103 id: hideSideStageDragArea
104 objectName: "hideSideStageDragArea"
105
106 direction: Direction.Rightwards
107 enabled: root.shown
108 anchors.right: root.left
109 width: sideStageDragHandle.width
110 height: root.height
111 stretch: true
112
113 immediateRecognition: true
114 maxTotalDragDistance: panelWidth
115 autoCompleteDragThreshold: panelWidth / 2
116 }
117
118 // SideStage mouse event eater
119 MouseArea {
120 anchors.fill: parent
121 }
122}