Warning, /plasma/plasma-workspace/components/containmentlayoutmanager/qml/ConfigOverlayWithHandles.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.12
0008 import QtQuick.Layouts 1.1
0009 
0010 import org.kde.kirigami 2.20 as Kirigami
0011 
0012 import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
0013 
0014 import "private"
0015 
0016 ContainmentLayoutManager.ConfigOverlay {
0017     id: overlay
0018 
0019     LayoutMirroring.enabled: false
0020     LayoutMirroring.childrenInherit: true
0021 
0022     opacity: open
0023     Behavior on opacity {
0024         OpacityAnimator {
0025             duration: Kirigami.Units.longDuration
0026             easing.type: Easing.InOutQuad
0027         }
0028     }
0029 
0030     MultiPointTouchArea {
0031         anchors.fill: parent
0032         property real previousMinX
0033         property real previousMinY
0034         property real previousMaxX
0035         property real previousMaxY
0036         property bool pinching: false
0037         mouseEnabled: false
0038         maximumTouchPoints: 2
0039         touchPoints: [
0040             TouchPoint { id: point1 },
0041             TouchPoint { id: point2 }
0042         ]
0043 
0044         onPressed: {
0045             overlay.itemContainer.layout.releaseSpace(overlay.itemContainer);
0046             previousMinX = point1.sceneX;
0047             previousMinY = point1.sceneY;
0048         }
0049 
0050         onUpdated: {
0051             let minX;
0052             let minY;
0053             let maxX;
0054             let maxY;
0055 
0056             if (point1.pressed && point2.pressed) {
0057                 minX = Math.min(point1.sceneX, point2.sceneX);
0058                 minY = Math.min(point1.sceneY, point2.sceneY);
0059 
0060                 maxX = Math.max(point1.sceneX, point2.sceneX);
0061                 maxY = Math.max(point1.sceneY, point2.sceneY);
0062             } else {
0063                 minX = point1.pressed ? point1.sceneX : point2.sceneX;
0064                 minY = point1.pressed ? point1.sceneY : point2.sceneY;
0065                 maxX = -1;
0066                 maxY = -1;
0067             }
0068 
0069             if (pinching === (point1.pressed && point2.pressed)) {
0070                 overlay.itemContainer.x += minX - previousMinX;
0071                 overlay.itemContainer.y += minY - previousMinY;
0072 
0073                 if (pinching) {
0074                     overlay.itemContainer.width += maxX - previousMaxX + previousMinX - minX;
0075                     overlay.itemContainer.height += maxY - previousMaxY + previousMinY - minY;
0076                 }
0077                 overlay.itemContainer.layout.showPlaceHolderForItem(overlay.itemContainer);
0078             }
0079 
0080             pinching = point1.pressed && point2.pressed
0081             previousMinX = minX;
0082             previousMinY = minY;
0083             previousMaxX = maxX;
0084             previousMaxY = maxY;
0085         }
0086         onReleased: {
0087             if (point1.pressed || point2.pressed) {
0088                 return;
0089             }
0090             overlay.itemContainer.layout.positionItem(overlay.itemContainer);
0091             overlay.itemContainer.layout.hidePlaceHolder();
0092             pinching = false;
0093         }
0094         onCanceled: released()
0095     }
0096 
0097     BasicResizeHandle {
0098         resizeCorner: ContainmentLayoutManager.ResizeHandle.TopLeft
0099         anchors {
0100             horizontalCenter: parent.left
0101             verticalCenter: parent.top
0102         }
0103     }
0104     BasicResizeHandle {
0105         resizeCorner: ContainmentLayoutManager.ResizeHandle.Left
0106         anchors {
0107             horizontalCenter: parent.left
0108             verticalCenter: parent.verticalCenter
0109         }
0110     }
0111     BasicResizeHandle {
0112         resizeCorner: ContainmentLayoutManager.ResizeHandle.BottomLeft
0113         anchors {
0114             horizontalCenter: parent.left
0115             verticalCenter: parent.bottom
0116         }
0117     }
0118     BasicResizeHandle {
0119         resizeCorner: ContainmentLayoutManager.ResizeHandle.Bottom
0120         anchors {
0121             horizontalCenter: parent.horizontalCenter
0122             verticalCenter: parent.bottom
0123         }
0124     }
0125     BasicResizeHandle {
0126         resizeCorner: ContainmentLayoutManager.ResizeHandle.BottomRight
0127         anchors {
0128             horizontalCenter: parent.right
0129             verticalCenter: parent.bottom
0130         }
0131     }
0132     BasicResizeHandle {
0133         resizeCorner: ContainmentLayoutManager.ResizeHandle.Right
0134         anchors {
0135             horizontalCenter: parent.right
0136             verticalCenter: parent.verticalCenter
0137         }
0138     }
0139     BasicResizeHandle {
0140         resizeCorner: ContainmentLayoutManager.ResizeHandle.TopRight
0141         anchors {
0142             horizontalCenter: parent.right
0143             verticalCenter: parent.top
0144         }
0145     }
0146     BasicResizeHandle {
0147         resizeCorner: ContainmentLayoutManager.ResizeHandle.Top
0148         anchors {
0149             horizontalCenter: parent.horizontalCenter
0150             verticalCenter: parent.top
0151         }
0152     }
0153 }