launcher: wallpapers default to current wall

This commit is contained in:
2 * r + 2 * t 2025-05-05 14:57:58 +10:00
parent 1fdaf24526
commit 552593424d

View file

@ -12,15 +12,19 @@ PathView {
required property Scope launcher
model: ScriptModel {
readonly property string search: root.search.text.split(" ").slice(1).join(" ")
values: {
const list = Wallpapers.fuzzyQuery(root.search.text.split(" ").slice(1).join(" "));
const list = Wallpapers.fuzzyQuery(search);
if (list.length > 1 && list.length % 2 === 0)
list.length -= 1; // Always show odd number
return list;
}
onValuesChanged: root.currentIndex = 0
onValuesChanged: root.currentIndex = search ? 0 : values.findIndex(w => w.path === Wallpapers.current)
}
Component.onCompleted: currentIndex = Wallpapers.list.findIndex(w => w.path === Wallpapers.current)
implicitWidth: Math.min(LauncherConfig.maxWallpapers, count) * (LauncherConfig.sizes.wallpaperWidth * 0.8 + Appearance.padding.larger * 2)
pathItemCount: LauncherConfig.maxWallpapers
cacheItemCount: 4