Skip to content

Commit

Permalink
fix: folder not support wheel event
Browse files Browse the repository at this point in the history
  • Loading branch information
kegechen committed Jun 19, 2024
1 parent a3eed07 commit bac03fe
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
27 changes: 27 additions & 0 deletions qml/FolderGridViewPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 2 additions & 22 deletions qml/FullscreenFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bac03fe

Please sign in to comment.