From dd039a612fef510cc8c598ab4f82098f24f86bad Mon Sep 17 00:00:00 2001 From: ronoaer Date: Wed, 20 Sep 2023 14:18:21 +0800 Subject: [PATCH] used position-changed to closes drawer --- client/ui/qml/Controls2/DrawerType.qml | 28 +++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/client/ui/qml/Controls2/DrawerType.qml b/client/ui/qml/Controls2/DrawerType.qml index 60db1e48f..c22d00c24 100644 --- a/client/ui/qml/Controls2/DrawerType.qml +++ b/client/ui/qml/Controls2/DrawerType.qml @@ -4,6 +4,7 @@ import QtQuick.Controls Drawer { id: drawer property bool needCloseButton: true + property bool isOpened: false Connections { target: PageController @@ -61,22 +62,39 @@ Drawer { } } + onOpened: { + isOpened = true + } + onClosed: { + isOpened = false + var initialPageNavigationBarColor = PageController.getInitialPageNavigationBarColor() if (initialPageNavigationBarColor !== 0xFF1C1D21) { PageController.updateNavigationBarColor(initialPageNavigationBarColor) } } + + onPositionChanged: { + if (isOpened && (position <= 0.99 && position >= 0.95)) { + mouseArea.canceled() + drawer.close() + mouseArea.exited() + dropArea.exited() + } + } + + DropArea { + id: dropArea + } + MouseArea { id: mouseArea anchors.fill: parent - onCanceled: { - Drag.cancel() - drawer.close() + onPressed: { + isOpened = true } - - preventStealing: false } }