/usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kirigami/templates/SplitDrawer.qml is in qml-module-org-kde-kirigami 1.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | /*
* Copyright 2012 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import org.kde.kirigami 1.0
import "private"
/**
* Split Drawers are used to expose additional UI elements which are optional
* and can be used in conjunction with the main UI elements.
* For example the Resource Browser uses a Split Drawer to select
* different kinds of filters for the main view.
*/
AbstractDrawer {
id: root
z:0
visible: true
/**
* page: Item
* It's the default property. it's the main content of the drawer page,
* the part that is always shown
*/
default property alias page: mainPage.data
/**
* contentItem: Item
* It's the part that can be pulled in and out, will act as a sidebar.
*/
property Item contentItem
/**
* opened: bool
* If true the drawer is open showing the contents of the "drawer"
* component.
*/
property alias opened: sidebar.open
/**
* position: real
* This property holds the position of the drawer relative to its
* final destination. That is, the position will be 0 when the
* drawer is fully closed, and 1 when fully open.
*/
property real position: 0
/**
* modal: bool
* If true the drawer will be an overlay of the main content,
* obscuring it and blocking input.
* If false, the drawer will look like a sidebar, with the main content
* application still usable.
* It is recomended to use modal on mobile devices and not modal on desktop
* devices.
* Default is true
*/
//property bool modal: true
/**
* background: Item
* This property holds the background item.
*
* Note: If the background item has no explicit size specified,
* it automatically follows the control's size.
* In most cases, there is no need to specify width or
* height for a background item.
*/
property Item background
onBackgroundChanged: {
background.parent = browserFrame;
background.anchors.fill = browserFrame;
background.z = -1;
}
Component.onCompleted: {
mainPage.width = browserFrame.width
contentItem.parent = drawerPage
}
onPositionChanged: {
if (!browserFrame.loopCheck) {
browserFrame.loopCheck = true;
browserFrame.x = position * drawerPage.width;
browserFrame.loopCheck = false;
}
}
onContentItemChanged: contentItem.parent = drawerPage
MouseArea {
id: mouseEventListener
z: 200
drag.filterChildren: true
//drag.target: browserFrame
property int startMouseX
property int oldMouseX
property int startBrowserFrameX
property bool toggle: false
property string startState
enabled: root.modal
anchors.fill: parent
onPressed: {
if (drawerPage.children.length == 0 || (browserFrame.state == "Closed" && mouse.x > Units.gridUnit) ||
mouse.x < browserFrame.x) {
mouse.accepted = false;
return;
}
toggle = true;
startBrowserFrameX = browserFrame.x;
oldMouseX = startMouseX = mouse.x;
startState = browserFrame.state;
browserFrame.state = "Dragging";
browserFrame.x = startBrowserFrameX;
}
onPositionChanged: {
browserFrame.x = Math.max(0, browserFrame.x + mouse.x - oldMouseX);
oldMouseX = mouse.x;
if (Math.abs(mouse.x - startMouseX) > Units.gridUnit * 2) {
toggle = false;
}
}
onReleased: {
if (toggle) {
browserFrame.state = startState == "Open" ? "Closed" : "Open"
} else if (browserFrame.x < drawerPage.width / 2) {
browserFrame.state = "Closed";
} else {
browserFrame.state = "Open";
}
}
onClicked: root.clicked()
}
Item {
id: browserFrame
z: 100
state: sidebar.open ? "Open" : "Closed"
onStateChanged: sidebar.open = (state != "Closed")
readonly property real position: Math.abs(x) / drawerPage.width
property bool loopCheck: false
onPositionChanged: {
if (!loopCheck) {
loopCheck = true;
root.position = position;
loopCheck = false;
}
}
anchors {
top: parent.top
bottom: parent.bottom
}
width: root.width;
Item {
id: mainPage
onChildrenChanged: mainPage.children[0].anchors.fill = mainPage
anchors.fill: parent
}
Rectangle {
anchors.fill: parent
color: "black"
opacity: Math.min(0.4, 0.4 * (browserFrame.x / drawerPage.width))
visible: root.modal
}
states: [
State {
name: "Open"
PropertyChanges {
target: browserFrame
x: drawerPage.width
}
},
State {
name: "Dragging"
PropertyChanges {
target: browserFrame
x: mouseEventListener.startBrowserFrameX
}
},
State {
name: "Closed"
PropertyChanges {
target: browserFrame
x: 0
}
}
]
transitions: [
Transition {
//Exclude Dragging
to: "Open,Closed,Hidden"
NumberAnimation {
properties: "x"
duration: Units.longDuration
easing.type: Easing.InOutQuad
}
}
]
}
Item {
id: sidebar
property bool open: false
onOpenChanged: {
if (drawerPage.children.length == 0) {
return;
}
if (open) {
browserFrame.state = "Open";
} else {
browserFrame.state = "Closed";
}
}
width: browserFrame.x
clip: true
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
}
Item {
id: drawerPage
width: Math.min(root.width/4*3, Math.max(root.contentItem ? root.contentItem.implicitWidth : 0, root.width/4))
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
topMargin: (applicationWindow !== undefined && applicationWindow().header) && modal ? applicationWindow().header.height : 0
}
clip: false
onChildrenChanged: drawerPage.children[0].anchors.fill = drawerPage
}
}
}
|