Handle the picker's mouse wheel on the tiles
The ListView's WheelHandler never fired: the tiles' MouseAreas receive wheel events first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
addf49800a
commit
27600ffd37
1 file changed
+11
-13
@@ -29,6 +29,16 @@ PanelWindow {
|
|||||||
Component.onDestruction:ShellState.wallpaperWindow=null
|
Component.onDestruction:ShellState.wallpaperWindow=null
|
||||||
property string filter:"all"
|
property string filter:"all"
|
||||||
readonly property var results:WallpaperService.images.filter(i=>(filter!=="history" || ConfigService.data.wallpaper.history.includes(i.path)) && (!search.text || i.name.toLowerCase().includes(search.text.toLowerCase())))
|
readonly property var results:WallpaperService.images.filter(i=>(filter!=="history" || ConfigService.data.wallpaper.history.includes(i.path)) && (!search.text || i.name.toLowerCase().includes(search.text.toLowerCase())))
|
||||||
|
// A vertical mouse wheel steps through the horizontal strip, one tile per notch.
|
||||||
|
// Handled on the tiles: their MouseAreas take wheel events before the ListView.
|
||||||
|
property real wheelPending:0
|
||||||
|
function wheelStep(event) {
|
||||||
|
wheelPending+=event.angleDelta.y || event.angleDelta.x;
|
||||||
|
const steps=Math.trunc(wheelPending/120);
|
||||||
|
if(!steps)return;
|
||||||
|
wheelPending-=steps*120;
|
||||||
|
view.currentIndex=Math.max(0,Math.min(view.count-1,view.currentIndex-steps));
|
||||||
|
}
|
||||||
function applyCurrent() {if(root.results[view.currentIndex])WallpaperService.apply(root.results[view.currentIndex].path);}
|
function applyCurrent() {if(root.results[view.currentIndex])WallpaperService.apply(root.results[view.currentIndex].path);}
|
||||||
Connections {
|
Connections {
|
||||||
target:ShellState
|
target:ShellState
|
||||||
@@ -91,18 +101,6 @@ PanelWindow {
|
|||||||
Keys.onReturnPressed:root.applyCurrent()
|
Keys.onReturnPressed:root.applyCurrent()
|
||||||
Keys.onEnterPressed:root.applyCurrent()
|
Keys.onEnterPressed:root.applyCurrent()
|
||||||
Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false
|
Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false
|
||||||
// A vertical mouse wheel steps through the horizontal strip, one tile per notch.
|
|
||||||
WheelHandler {
|
|
||||||
property real pending:0
|
|
||||||
acceptedDevices:PointerDevice.Mouse
|
|
||||||
onWheel:event=>{
|
|
||||||
pending+=event.angleDelta.y || event.angleDelta.x;
|
|
||||||
const steps=Math.trunc(pending/120);
|
|
||||||
if(!steps)return;
|
|
||||||
pending-=steps*120;
|
|
||||||
view.currentIndex=Math.max(0,Math.min(view.count-1,view.currentIndex-steps));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delegate:GlassPanel {
|
delegate:GlassPanel {
|
||||||
id:tile
|
id:tile
|
||||||
required property var modelData
|
required property var modelData
|
||||||
@@ -115,7 +113,7 @@ PanelWindow {
|
|||||||
Rectangle {anchors.bottom:parent.bottom;anchors.left:parent.left;anchors.right:parent.right;anchors.margins:6;height:42;color:Qt.alpha(Theme.surface,0.85)
|
Rectangle {anchors.bottom:parent.bottom;anchors.left:parent.left;anchors.right:parent.right;anchors.margins:6;height:42;color:Qt.alpha(Theme.surface,0.85)
|
||||||
Text {anchors.fill:parent;anchors.margins:10;text:(WallpaperService.currentPath===tile.modelData.path?"✓ ":"")+tile.modelData.name;color:Theme.text;elide:Text.ElideMiddle}
|
Text {anchors.fill:parent;anchors.margins:10;text:(WallpaperService.currentPath===tile.modelData.path?"✓ ":"")+tile.modelData.name;color:Theme.text;elide:Text.ElideMiddle}
|
||||||
}
|
}
|
||||||
MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();WallpaperService.apply(tile.modelData.path);}}
|
MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();WallpaperService.apply(tile.modelData.path);}onWheel:event=>root.wheelStep(event)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text {visible:!root.results.length;text:WallpaperService.scanning ? "Loading wallpapers…" : "No wallpapers here. Choose a folder in Wallpaper settings.";color:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
Text {visible:!root.results.length;text:WallpaperService.scanning ? "Loading wallpapers…" : "No wallpapers here. Choose a folder in Wallpaper settings.";color:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
||||||
|
|||||||
Reference in new issue
Block a user