SetupWallpaperStep: add scrollwheel support

This commit is contained in:
Ly-sec
2025-10-30 12:42:42 +01:00
parent 3dd02b8367
commit c0e5d7d419
2 changed files with 25 additions and 2 deletions
@@ -199,11 +199,34 @@ ColumnLayout {
visible: filteredWallpapers.length > 0
ScrollView {
id: galleryScroll
anchors.fill: parent
clip: true
ScrollBar.horizontal.policy: ScrollBar.AsNeeded
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
// Enable vertical mouse wheel to scroll the horizontal strip by moving contentX
WheelHandler {
target: galleryScroll.contentItem
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
const flick = galleryScroll.contentItem
if (!flick)
return
const delta = event.pixelDelta.x !== 0 || event.pixelDelta.y !== 0 ? (event.pixelDelta.y !== 0 ? event.pixelDelta.y : event.pixelDelta.x) : (event.angleDelta.y !== 0 ? event.angleDelta.y : event.angleDelta.x)
// Move opposite of wheel to scroll content to the right for wheel down
const step = -delta
const maxX = Math.max(0, flick.contentWidth - flick.width)
let newX = flick.contentX + step
if (newX < 0)
newX = 0
if (newX > maxX)
newX = maxX
flick.contentX = newX
event.accepted = true
}
}
RowLayout {
spacing: Style.marginM
height: parent.height
+2 -2
View File
@@ -377,12 +377,12 @@ Singleton {
var scanner = wallpaperScanners.objectAt(i)
if (scanner) {
// Capture scanner in closure
(function(s) {
(function (s) {
var directory = root.getMonitorDirectory(s.screenName)
// Trigger a change by setting to /tmp (always exists) then back to the actual directory
// Note: This causes harmless Qt warnings (QTBUG-52262) but is necessary to force FolderListModel to re-scan
s.currentDirectory = "/tmp"
Qt.callLater(function() {
Qt.callLater(function () {
s.currentDirectory = directory
})
})(scanner)