From da6b21ca6d77c494a2f4c40a70fc5429902df115 Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Tue, 23 Jan 2024 12:43:32 -0800 Subject: [PATCH] Support back and forward buttons. --- qml/FolderGridView.qml | 9 +++++++++ qml/FolderListView.qml | 10 ++++++++++ qml/FolderPage.qml | 12 ++++++++++++ 3 files changed, 31 insertions(+) diff --git a/qml/FolderGridView.qml b/qml/FolderGridView.qml index feae33b..c618d2b 100644 --- a/qml/FolderGridView.qml +++ b/qml/FolderGridView.qml @@ -65,6 +65,8 @@ GridView { property bool scrollDown: false signal keyPress(var event) + signal backPress() + signal forwardPress() cacheBuffer: Math.max(0, control.height * 1.5) reuseItems: true @@ -469,6 +471,13 @@ GridView { onClicked: { clearPressState() + if (mouse.buttons & Qt.BackButton) { + control.backPress() + } + if (mouse.buttons & Qt.ForwardButton){ + control.forwardPress() + } + if (mouse.buttons & Qt.RightButton) { dirModel.openContextMenu(null, mouse.modifiers) } diff --git a/qml/FolderListView.qml b/qml/FolderListView.qml index a2c5b2a..f2851c6 100644 --- a/qml/FolderListView.qml +++ b/qml/FolderListView.qml @@ -52,6 +52,8 @@ ListView { property variant cachedRectangleSelection: null signal keyPress(var event) + signal backPress() + signal forwardPress() clip: true cacheBuffer: width @@ -288,12 +290,20 @@ ListView { dirModel.openContextMenu(null, mouse.modifiers) mouse.accepted = true } + } } onClicked: { clearPressState() + if (mouse.buttons & Qt.BackButton) { + control.backPress() + } + if (mouse.buttons & Qt.ForwardButton){ + control.forwardPress() + } + if (!hoveredItem || hoveredItem.blank || control.currentIndex === -1 || control.ctrlPressed || control.shiftPressed) { return diff --git a/qml/FolderPage.qml b/qml/FolderPage.qml index 82d4900..8b62741 100644 --- a/qml/FolderPage.qml +++ b/qml/FolderPage.qml @@ -337,6 +337,12 @@ Item { onCountChanged: { _fileTips.visible = count === 0 } + onForwardPressed: { + dirModel.goForward(); + } + onBackPressed:{ + dirModel.goBack(); + } } } @@ -356,6 +362,12 @@ Item { onCountChanged: { _fileTips.visible = count === 0 } + onForwardPressed: { + dirModel.goForward(); + } + onBackPressed:{ + dirModel.goBack(); + } delegate: FolderListItem {} }