diff --git a/qml/FolderGridViewPopup.qml b/qml/FolderGridViewPopup.qml index e742397a..1298b448 100644 --- a/qml/FolderGridViewPopup.qml +++ b/qml/FolderGridViewPopup.qml @@ -130,6 +130,33 @@ Popup { Layout.fillWidth: true Layout.fillHeight: true color: "transparent" + MouseArea { + anchors.fill: parent + scrollGestureEnabled: false + + // TODO: this might not be the correct way to handle wheel + onWheel: { + let xDelta = wheel.angleDelta.x / 8 + let yDelta = wheel.angleDelta.y / 8 + let toPage = 0; // -1 prev, +1 next, 0 don't change + if (yDelta !== 0) { + toPage = (yDelta > 0) ? -1 : 1 + } else if (xDelta !== 0) { + toPage = (xDelta > 0) ? 1 : -1 + } + if (toPage < 0) { + if (!searchEdit.focus) { // reset keyboard focus when using mouse to flip page, but keep searchEdit focus + baseLayer.focus = true + } + decrementPageIndex(folderPagesView) + } else if (toPage > 0) { + if (!searchEdit.focus) { // reset keyboard focus when using mouse to flip page, but keep searchEdit focus + baseLayer.focus = true + } + incrementPageIndex(folderPagesView) + } + } + } SwipeView { id: folderPagesView diff --git a/qml/FullscreenFrame.qml b/qml/FullscreenFrame.qml index 4b3cd9a6..522a215d 100644 --- a/qml/FullscreenFrame.qml +++ b/qml/FullscreenFrame.qml @@ -67,26 +67,6 @@ Control { ItemArrangementProxyModel.removeEmptyPage() } - function decrementPageIndex() { - if (pages.currentIndex === 0 && pages.count > 1) { - // pages.setCurrentIndex(pages.count - 1) - } else { - pages.decrementCurrentIndex() - } - - closeContextMenu() - } - - function incrementPageIndex() { - if (pages.currentIndex === pages.count - 1 && pages.count > 1) { - // pages.setCurrentIndex(0) - } else { - pages.incrementCurrentIndex() - } - - closeContextMenu() - } - Timer { id: flipPageDelay interval: 400 @@ -124,13 +104,13 @@ Control { if (!searchEdit.focus) { // reset keyboard focus when using mouse to flip page, but keep searchEdit focus baseLayer.focus = true } - decrementPageIndex() + decrementPageIndex(pages) } else if (toPage > 0) { flipPageDelay.start() if (!searchEdit.focus) { // reset keyboard focus when using mouse to flip page, but keep searchEdit focus baseLayer.focus = true } - incrementPageIndex() + incrementPageIndex(pages) } } } diff --git a/qml/Main.qml b/qml/Main.qml index 6a9346dc..a347fc68 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -88,6 +88,26 @@ QtObject { } } + function decrementPageIndex(pages) { + if (pages.currentIndex === 0 && pages.count > 1) { + // pages.setCurrentIndex(pages.count - 1) + } else { + pages.decrementCurrentIndex() + } + + closeContextMenu() + } + + function incrementPageIndex(pages) { + if (pages.currentIndex === pages.count - 1 && pages.count > 1) { + // pages.setCurrentIndex(0) + } else { + pages.incrementCurrentIndex() + } + + closeContextMenu() + } + function descaledRect(rect) { let ratio = Screen.devicePixelRatio return Qt.rect(rect.left / ratio, rect.top / ratio, rect.width / ratio, rect.height / ratio)