2
* Copyright 2012 Marco Martin <mart@kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License as
6
* published by the Free Software Foundation; either version 2, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Library General Public License for more details
14
* You should have received a copy of the GNU Library General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
import org.kde.plasma.components 0.1 as PlasmaComponents
22
import org.kde.plasma.core 0.1 as PlasmaCore
23
import org.kde.qtextracomponents 0.1
28
Page from org.kde.plasmacomponents
32
org.kde.plasma.components
36
Overlay Drawers are used to expose additional UI elements needed for small secondary tasks for which the main UI elements are not needed. For example in Okular Active, an Overlay Drawer is used to display thumbnails of all pages within a document along with a search field. This is used for the distinct task of navigating to another page.
40
If true the drawer is open showing the contents of the "drawer" component.
43
It's the default property. it's the main content of the drawer page, the part that is always shown
46
It's the part that can be pulled in and out, will act as a sidebar.
48
PlasmaComponents.Page {
52
default property alias page: mainPage.data
53
property alias drawer: drawerPage.data
54
property alias open: browserFrame.open
59
property int startMouseScreenX: 0
60
property int startMouseScreenY: 0
62
startMouseScreenX = mouse.screenX
63
startMouseScreenY = mouse.screenY
66
if (Math.abs(mouse.screenX - startMouseScreenX) > 20 ||
67
Math.abs(mouse.screenY - startMouseScreenY) > 20) {
70
if (browserFrame.state != "Hidden") {
71
browserFrame.state = "Hidden"
73
browserFrame.state = "Closed"
82
source: "image://appbackgrounds/standard"
89
width: parent.width - handleGraphics.width
91
onStateChanged: open = (state == "Open" || mouseEventListener.startState == "Open")
92
property bool open: false
93
onOpenChanged: openChangedTimer.restart()
100
browserFrame.state = "Open"
102
browserFrame.state = "Closed"
109
source: "image://appbackgrounds/shadow-left"
110
fillMode: Image.TileVertically
114
bottom: parent.bottom
118
PlasmaCore.FrameSvgItem {
120
imagePath: "dialogs/background"
121
enabledBorders: "LeftBorder|TopBorder|BottomBorder"
122
width: handleIcon.width + margins.left + margins.right + 4
123
height: handleIcon.width * 1.6 + margins.top + margins.bottom + 4
126
verticalCenter: parent.verticalCenter
131
svg: PlasmaCore.Svg {imagePath: "toolbar-icons/show"}
132
elementId: "show-menu"
133
x: parent.margins.left
134
y: parent.margins.top
135
width: theme.smallMediumIconSize
137
anchors.verticalCenter: parent.verticalCenter
142
id: mouseEventListener
145
bottom: parent.bottom
146
left: handleGraphics.left
150
property int startBrowserFrameX
151
property real oldMouseScreenX
152
property bool toggle: false
153
property bool startDragging: false
154
property string startState
157
startBrowserFrameX = browserFrame.x
158
oldMouseScreenX = mouse.screenX
159
startMouseScreenX = mouse.screenX
160
toggle = (mouse.x < handleGraphics.width)
161
startDragging = false
162
startState = browserFrame.state
163
browserFrame.state = "Dragging"
164
toggle = mouse.x < handleGraphics.width
167
//mouse over handle and didn't move much
168
if (mouse.x > handleGraphics.width ||
169
Math.abs(mouse.screenX - startMouseScreenX) > 20) {
172
if (mouse.x < handleGraphics.width ||
173
Math.abs(mouse.screenX - startMouseScreenX) > root.width / 5) {
177
browserFrame.x = Math.max(root.width - browserFrame.width, browserFrame.x + mouse.screenX - oldMouseScreenX)
179
oldMouseScreenX = mouse.screenX
182
//If one condition for toggle is satisfied toggle, otherwise do an animation that resets the original position
183
if (toggle || Math.abs(browserFrame.x - startBrowserFrameX) > root.width / 3) {
184
browserFrame.state = startState == "Open" ? "Closed" : "Open"
186
browserFrame.state = startState
194
leftMargin: handleGraphics.width
205
x: handleGraphics.width
211
//workaround for a quirkiness of the state machine
212
//if no x binding gets defined in this state x will be set to whatever last x it had last time it was in this state
215
x: mouseEventListener.startBrowserFrameX
229
x: root.width + handleGraphics.width
237
to: "Open,Closed,Hidden"
241
easing.type: Easing.InOutQuad