Warning, /plasma/plasma-mobile/components/mobileshell/qml/actiondrawer/ActionDrawerOpenSurface.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 0009 import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings 0010 import org.kde.plasma.private.mobileshell as MobileShell 0011 0012 /** 0013 * Component that triggers the opening and closing of an ActionDrawer when dragged on with touch or mouse. 0014 */ 0015 MobileShell.SwipeArea { 0016 id: root 0017 mode: MobileShell.SwipeArea.VerticalOnly 0018 0019 required property ActionDrawer actionDrawer 0020 0021 property int oldMouseY: 0 0022 0023 function startSwipe() { 0024 if (actionDrawer.visible) { 0025 // ensure the action drawer state is consistent 0026 actionDrawer.closeImmediately(); 0027 } 0028 actionDrawer.cancelAnimations(); 0029 actionDrawer.dragging = true; 0030 actionDrawer.opened = false; 0031 0032 // must be after properties other are set, we cannot have actionDrawer.updateState() be called 0033 actionDrawer.offset = 0; 0034 actionDrawer.oldOffset = 0; 0035 actionDrawer.visible = true; 0036 } 0037 0038 function endSwipe() { 0039 actionDrawer.dragging = false; 0040 actionDrawer.updateState(); 0041 } 0042 0043 function updateOffset(offsetY) { 0044 actionDrawer.offset += offsetY; 0045 } 0046 0047 anchors.fill: parent 0048 0049 onSwipeStarted: (point) => { 0050 // if the user swiped from the top left, otherwise it's from the top right 0051 if (point.x < root.width / 2) { 0052 actionDrawer.openToPinnedMode = ShellSettings.Settings.actionDrawerTopLeftMode == ShellSettings.Settings.Pinned; 0053 } else { 0054 actionDrawer.openToPinnedMode = ShellSettings.Settings.actionDrawerTopRightMode == ShellSettings.Settings.Pinned; 0055 } 0056 0057 startSwipe(); 0058 } 0059 onSwipeEnded: endSwipe() 0060 onSwipeMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => updateOffset(deltaY); 0061 }