Skip to content

Commit

Permalink
Use drawer to show actions on files page in Qt Quick GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed Jan 31, 2025
1 parent ad604f1 commit 5471173
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
34 changes: 34 additions & 0 deletions tray/gui/qml/FilesPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -219,4 +248,9 @@ Page {
}
return isValid;
}

function showExtraActions() {
extraActionsDrawer.open();
return true;
}
}
8 changes: 6 additions & 2 deletions tray/gui/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? [];
}
}
}
}
Expand Down

0 comments on commit 5471173

Please sign in to comment.