From c0e5d7d4195e1a56052af9b36ef24f7bb20632c7 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Thu, 30 Oct 2025 12:42:42 +0100 Subject: [PATCH] SetupWallpaperStep: add scrollwheel support --- Modules/SetupWizard/SetupWallpaperStep.qml | 23 ++++++++++++++++++++++ Services/WallpaperService.qml | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Modules/SetupWizard/SetupWallpaperStep.qml b/Modules/SetupWizard/SetupWallpaperStep.qml index aa915f72..4725247d 100644 --- a/Modules/SetupWizard/SetupWallpaperStep.qml +++ b/Modules/SetupWizard/SetupWallpaperStep.qml @@ -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 diff --git a/Services/WallpaperService.qml b/Services/WallpaperService.qml index b923365f..864a041f 100644 --- a/Services/WallpaperService.qml +++ b/Services/WallpaperService.qml @@ -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)