/usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kirigami/private/ActionButton.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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | /*
* Copyright 2015 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 QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
import org.kde.kirigami 1.0
import "../templates/private"
Item {
id: root
anchors {
left: parent.left
right: parent.right
bottom:parent.bottom
}
//smallSpacing for the shadow
height: button.height + Units.smallSpacing
clip: true
//either Action or QAction should work here
property QtObject action: root.parent.parent ? root.parent.parent.mainAction : null
property QtObject leftAction: root.parent.parent ? root.parent.parent.leftAction : null
property QtObject rightAction: root.parent.parent ? root.parent.parent.rightAction : null
onWidthChanged: button.x = root.width/2 - button.width/2
transform: Translate {
id: translateTransform
}
Item {
id: button
anchors {
bottom: parent.bottom
bottomMargin: Units.smallSpacing
}
implicitWidth: implicitHeight + Units.iconSizes.smallMedium*3
implicitHeight: Units.iconSizes.large + Units.largeSpacing
onXChanged: {
if (mouseArea.pressed || edgeMouseArea.pressed || fakeContextMenuButton.pressed) {
if (globalDrawer && globalDrawer.enabled && globalDrawer.modal) {
globalDrawer.position = Math.min(1, Math.max(0, (x - root.width/2 + button.width/2)/globalDrawer.contentItem.width + mouseArea.drawerShowAdjust));
}
if (contextDrawer && contextDrawer.enabled && contextDrawer.modal) {
contextDrawer.position = Math.min(1, Math.max(0, (root.width/2 - button.width/2 - x)/contextDrawer.contentItem.width + mouseArea.drawerShowAdjust));
}
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
visible: action != null || leftAction != null || rightAction != null
property bool internalVisibility: (applicationWindow === undefined || (applicationWindow().controlsVisible && applicationWindow().height > root.height*2)) && (root.action === null || root.action.visible === undefined || root.action.visible)
preventStealing: true
onInternalVisibilityChanged: {
showAnimation.running = false;
if (internalVisibility) {
showAnimation.to = 0;
} else {
showAnimation.to = button.height;
}
showAnimation.running = true;
}
drag {
target: button
//filterChildren: true
axis: Drag.XAxis
minimumX: contextDrawer && contextDrawer.enabled && contextDrawer.modal ? 0 : root.width/2 - button.width/2
maximumX: globalDrawer && globalDrawer.enabled && globalDrawer.modal ? root.width : root.width/2 - button.width/2
}
property var downTimestamp;
property int startX
property int startMouseY
property real drawerShowAdjust
property bool buttonPressedUnderMouse: false
property bool leftButtonPressedUnderMouse: false
property bool rightButtonPressedUnderMouse: false
onPressed: {
//search if we have a page to set to current
if (applicationWindow !== undefined && applicationWindow().pageStack.currentIndex !== undefined) {
//search the button parent's parent, that is the page parent
//this will make the context drawer open for the proper page
applicationWindow().pageStack.currentIndex = root.parent.parent.parent.level;
}
downTimestamp = (new Date()).getTime();
startX = button.x + button.width/2;
startMouseY = mouse.y;
drawerShowAdjust = 0;
buttonPressedUnderMouse = mouse.x > buttonGraphics.x && mouse.x < buttonGraphics.x + buttonGraphics.width;
leftButtonPressedUnderMouse = !buttonPressedUnderMouse && leftAction && mouse.x < buttonGraphics.x;
rightButtonPressedUnderMouse = !buttonPressedUnderMouse && rightAction && mouse.x > buttonGraphics.x + buttonGraphics.width;
}
onReleased: {
//pixel/second
var x = button.x + button.width/2;
var speed = ((x - startX) / ((new Date()).getTime() - downTimestamp) * 1000);
drawerShowAdjust = 0;
//project where it would be a full second in the future
if (globalDrawer && globalDrawer.modal && x + speed > Math.min(root.width/4*3, root.width/2 + globalDrawer.contentItem.width/2)) {
globalDrawer.open();
contextDrawer.close();
} else if (contextDrawer && x + speed < Math.max(root.width/4, root.width/2 - contextDrawer.contentItem.width/2)) {
if (contextDrawer && contextDrawer.modal) {
contextDrawer.open();
}
if (globalDrawer && globalDrawer.modal) {
globalDrawer.close();
}
} else {
if (globalDrawer && globalDrawer.modal) {
globalDrawer.close();
}
if (contextDrawer && contextDrawer.modal) {
contextDrawer.close();
}
}
//Don't rely on native onClicked, but fake it here:
//Qt.startDragDistance is not adapted to devices dpi in case
//of Android, so consider the button "clicked" when:
//*the button has been dragged less than a gridunit
//*the finger is still on the button
if (Math.abs((button.x + button.width/2) - startX) < Units.gridUnit &&
mouse.y > 0) {
var action;
if (buttonPressedUnderMouse) {
action = root.action;
} else if (leftButtonPressedUnderMouse) {
action = root.leftAction;
} else if (rightButtonPressedUnderMouse) {
action = root.rightAction;
}
if (!action) {
return;
}
//if an action has been assigned, trigger it
if (action && action.trigger) {
action.trigger();
}
}
}
onPositionChanged: {
drawerShowAdjust = Math.min(0.3, Math.max(0, (startMouseY - mouse.y)/(Units.gridUnit*15)));
button.xChanged();
}
onPressAndHold: {
var action;
if (buttonPressedUnderMouse) {
action = root.action;
} else if (leftButtonPressedUnderMouse) {
action = root.leftAction;
} else if (rightButtonPressedUnderMouse) {
action = root.rightAction;
}
if (!action) {
return;
}
//if an action has been assigned, show a message like a tooltip
if (action && action.text) {
showPassiveNotification(action.text);
}
}
Connections {
target: globalDrawer
onPositionChanged: {
if ( globalDrawer && globalDrawer.modal && !mouseArea.pressed && !edgeMouseArea.pressed && !fakeContextMenuButton.pressed) {
button.x = globalDrawer.contentItem.width * globalDrawer.position + root.width/2 - button.width/2;
}
}
}
Connections {
target: contextDrawer
onPositionChanged: {
if (contextDrawer && contextDrawer.modal && !mouseArea.pressed && !edgeMouseArea.pressed && !fakeContextMenuButton.pressed) {
button.x = root.width/2 - button.width/2 - contextDrawer.contentItem.width * contextDrawer.position;
}
}
}
NumberAnimation {
id: showAnimation
target: translateTransform
properties: "y"
duration: Units.longDuration
easing.type: mouseArea.internalVisibility == true ? Easing.InQuad : Easing.OutQuad
}
Item {
id: background
anchors {
fill: parent
}
Rectangle {
id: buttonGraphics
radius: width/2
anchors.centerIn: parent
height: parent.height - Units.smallSpacing*2
width: height
visible: root.action
readonly property bool pressed: root.action && ((mouseArea.buttonPressedUnderMouse && mouseArea.pressed) || root.action.checked)
color: pressed ? Theme.highlightColor : Theme.backgroundColor
Icon {
id: icon
source: root.action && root.action.iconName ? root.action.iconName : ""
selected: buttonGraphics.pressed
anchors {
fill: parent
margins: Units.smallSpacing
}
}
Behavior on color {
ColorAnimation {
duration: Units.longDuration
easing.type: Easing.InOutQuad
}
}
Behavior on x {
NumberAnimation {
duration: Units.longDuration
easing.type: Easing.InOutQuad
}
}
}
//left button
Rectangle {
id: leftButtonGraphics
z: -1
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
radius: Units.smallSpacing
height: Units.iconSizes.medium + Units.smallSpacing * 2
width: height + (root.action ? Units.iconSizes.smallMedium : 0)
visible: root.leftAction
readonly property bool pressed: root.leftAction && ((mouseArea.leftButtonPressedUnderMouse && mouseArea.pressed) || root.leftAction.checked)
color: pressed ? Theme.highlightColor : Theme.backgroundColor
Icon {
source: root.leftAction && root.leftAction.iconName ? root.leftAction.iconName : ""
width: height
selected: leftButtonGraphics.pressed
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
margins: Units.smallSpacing
}
}
}
//right button
Rectangle {
id: rightButtonGraphics
z: -1
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
radius: Units.smallSpacing
height: Units.iconSizes.medium + Units.smallSpacing * 2
width: height + (root.action ? Units.iconSizes.smallMedium : 0)
visible: root.rightAction
readonly property bool pressed: root.rightAction && ((mouseArea.rightButtonPressedUnderMouse && mouseArea.pressed) || root.rightAction.checked)
color: pressed ? Theme.highlightColor : Theme.backgroundColor
Icon {
source: root.rightAction && root.rightAction.iconName ? root.rightAction.iconName : ""
width: height
selected: rightButtonGraphics.pressed
anchors {
right: parent.right
top: parent.top
bottom: parent.bottom
margins: Units.smallSpacing
}
}
}
}
DropShadow {
anchors.fill: background
horizontalOffset: 0
verticalOffset: Units.smallSpacing/3
radius: Units.gridUnit / 3.5
samples: 16
color: Qt.rgba(0, 0, 0, 0.5)
source: background
}
}
}
MouseArea {
id: fakeContextMenuButton
anchors {
right: edgeMouseArea.right
bottom: edgeMouseArea.bottom
margins: -1
}
drag {
target: button
//filterChildren: true
axis: Drag.XAxis
minimumX: contextDrawer && contextDrawer.enabled && contextDrawer.modal ? 0 : root.width/2 - button.width/2
maximumX: globalDrawer && globalDrawer.enabled && globalDrawer.modal ? root.width : root.width/2 - button.width/2
}
visible: root.parent.parent.actions.contextualActions.length > 0 && (applicationWindow === undefined || applicationWindow().wideScreen)
width: Units.iconSizes.medium + Units.smallSpacing * 2
height: width
Item {
opacity: 0.4
anchors {
fill:parent
margins: -Units.gridUnit
}
layer.enabled: true
Rectangle {
id: shadowRect
anchors {
fill: parent
margins: Units.gridUnit
}
color: "black"
}
FastBlur {
z: -1
anchors.fill: shadowRect
source: shadowRect
radius: Units.gridUnit
transparentBorder: true
}
Rectangle {
color: Theme.viewBackgroundColor
anchors {
fill:parent
margins: Units.gridUnit
}
}
}
ContextIcon {
anchors.centerIn: parent
width: height
height: Units.iconSizes.smallMedium - Units.smallSpacing * 2
}
onPressed: mouseArea.onPressed(mouse)
onReleased: {
var pos = root.mapFromItem(fakeContextMenuButton, mouse.x, mouse.y);
if (pos.x < root.width/2 || (!contextDrawer.opened && mouse.x > 0 && mouse.x < width)) {
contextDrawer.open();
} else if (contextDrawer.opened && mouse.x > 0 && mouse.x < width) {
contextDrawer.close();
}
if (globalDrawer.position > 0.5) {
globalDrawer.open();
} else {
globalDrawer.close();
}
}
}
MouseArea {
id: edgeMouseArea
z:99
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
drag {
target: button
//filterChildren: true
axis: Drag.XAxis
minimumX: contextDrawer && contextDrawer.enabled && contextDrawer.modal ? 0 : root.width/2 - button.width/2
maximumX: globalDrawer && globalDrawer.enabled && globalDrawer.modal ? root.width : root.width/2 - button.width/2
}
height: Units.smallSpacing * 3
onPressed: mouseArea.onPressed(mouse)
onPositionChanged: mouseArea.positionChanged(mouse)
onReleased: mouseArea.released(mouse)
}
}
|