mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
SetupWallpaperStep: add scrollwheel support
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user