From 54711731ad8c46efbb48b3285520ceb84261f448 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 1 Feb 2025 00:47:04 +0100 Subject: [PATCH] Use drawer to show actions on files page in Qt Quick GUI --- tray/gui/qml/FilesPage.qml | 34 ++++++++++++++++++++++++++++++++++ tray/gui/qml/Main.qml | 8 ++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/tray/gui/qml/FilesPage.qml b/tray/gui/qml/FilesPage.qml index 7e6bd22c..ce05e9ae 100644 --- a/tray/gui/qml/FilesPage.qml +++ b/tray/gui/qml/FilesPage.qml @@ -201,6 +201,35 @@ Page { confirmActionDialog.open(); } } + Drawer { + id: extraActionsDrawer + width: window.width + contentHeight: Math.min(drawerListView.contentHeight, window.height) + edge: Qt.BottomEdge + CustomListView { + id: drawerListView + anchors.fill: parent + model: page.extraActions + delegate: ItemDelegate { + id: drawerDelegate + width: drawerListView.width + text: modelData.text + enabled: modelData.enabled + visible: enabled + height: visible ? implicitHeight : 0 + onClicked: modelData?.trigger() + contentItem: RowLayout { + Label { + Layout.fillWidth: true + text: drawerDelegate.text + elide: Text.ElideRight + wrapMode: Text.WordWrap + } + } + required property Action modelData + } + } + } required property string dirName required property string dirId @@ -219,4 +248,9 @@ Page { } return isValid; } + + function showExtraActions() { + extraActionsDrawer.open(); + return true; + } } diff --git a/tray/gui/qml/Main.qml b/tray/gui/qml/Main.qml index 72157137..2ed0c5ab 100644 --- a/tray/gui/qml/Main.qml +++ b/tray/gui/qml/Main.qml @@ -139,13 +139,17 @@ ApplicationWindow { visible: pageStack.currentExtraActions.length > 0 icon.source: App.faUrlBase + "ellipsis-v" text: qsTr("More") - onClicked: extraActionsMenu.popup() + onClicked: pageStack.currentPage?.showExtraActions() ?? extraActionsMenu.popup() Menu { id: extraActionsMenu popupType: App.nativePopups ? Popup.Native : Popup.Item MenuItemInstantiator { menu: extraActionsMenu - model: pageStack.currentExtraActions + model: { + const currentPage = pageStack.currentPage; + const extraActions = currentPage.showExtraActions === undefined ? currentPage.extraActions : undefined; + return extraActions ?? []; + } } } }