actiondrawer: use action drawer window as the open surface area

Change to use the action drawer window as the open surface area so that we can open the drawer within fullscreen applications.
This commit is contained in:
Micah Stanley 2024-11-14 03:31:10 +00:00 committed by Devin Lin
parent 36f0d175fd
commit e4d57d19bc
3 changed files with 41 additions and 13 deletions

View file

@ -10,6 +10,7 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell as MobileShell
@ -272,15 +273,35 @@ Item {
mode: MobileShell.SwipeArea.VerticalOnly
anchors.fill: parent
function startSwipe() {
function startSwipeWithPoint(point) {
root.cancelAnimations();
root.dragging = true;
// Immediately open action drawer if we interact with it and it's already open
// This allows us to have 2 quick flicks from minimized -> expanded
if (root.visible && !root.opened) {
if (root.intendedToBeVisible && !root.opened) {
root.opened = true;
}
// if the user swiped from the top left, otherwise it's from the top right
if (!root.intendedToBeVisible) {
if (point.x < root.width / 2) {
root.openToPinnedMode = ShellSettings.Settings.actionDrawerTopLeftMode == ShellSettings.Settings.Pinned;
} else {
root.openToPinnedMode = ShellSettings.Settings.actionDrawerTopRightMode == ShellSettings.Settings.Pinned;
}
if (root.intendedToBeVisible) {
// ensure the action drawer state is consistent
root.closeImmediately();
}
actionDrawer.offset = 0;
actionDrawer.oldOffset = 0;
intendedToBeVisible = true;
}
}
function endSwipe() {
@ -292,7 +313,7 @@ Item {
root.offset += deltaY;
}
onSwipeStarted: startSwipe()
onSwipeStarted: (point) => startSwipeWithPoint(point)
onSwipeEnded: endSwipe()
onSwipeMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => moveSwipe(totalDeltaX, totalDeltaY, deltaX, deltaY)
@ -304,6 +325,8 @@ Item {
id: contentContainer
anchors.fill: parent
opacity: root.opened || swipeArea.moving || drawerAnimation.running || root.offset > 0 || root.intendedToBeVisible ? 1 : 0
actionDrawer: root
quickSettingsModel: root.quickSettingsModel
}

View file

@ -9,6 +9,7 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1
import QtQuick.Window
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.layershell 1.0 as LayerShell
@ -32,17 +33,28 @@ Window {
* The ActionDrawer component.
*/
property alias actionDrawer: drawer
property alias intendedToBeVisible: drawer.intendedToBeVisible
property alias state: drawer.state
visible: drawer.intendedToBeVisible
visible: true
color: "transparent"
onVisibleChanged: {
if (visible) {
Component.onCompleted: updateTouchArea()
function updateTouchArea() {
if (state != "" && state != "close") {
window.raise();
ShellUtil.setInputRegion(window, Qt.rect(0, 0, 0, 0));
} else {
ShellUtil.setInputRegion(window, Qt.rect(0, 0, window.width, MobileShell.Constants.topPanelHeight));
}
}
onWidthChanged: updateTouchArea()
onIntendedToBeVisibleChanged: updateTouchArea()
onStateChanged: updateTouchArea()
onActiveChanged: {
if (!active) {
drawer.close();

View file

@ -122,13 +122,6 @@ ContainmentItem {
backgroundColor: !root.showingApp ? "transparent" : root.backgroundColor
}
// swiping area for swipe-down drawer
MobileShell.ActionDrawerOpenSurface {
id: swipeArea
actionDrawer: drawer.actionDrawer
anchors.fill: parent
}
// swipe-down drawer component
MobileShell.ActionDrawerWindow {
id: drawer