diff options
| author | Laurens Duin <85798751+Laurens256@users.noreply.github.com> | 2025-08-05 06:31:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-05 14:31:40 +1000 |
| commit | e4d4c457f867bc6b5b33a8671fdd112425ec4b28 (patch) | |
| tree | 38ff4e330349b2c1a7bb3f908f1fece25d44ac4b /modules | |
| parent | internal: use device scaling for image caching (#348) (diff) | |
| download | caelestia-shell-e4d4c457f867bc6b5b33a8671fdd112425ec4b28.tar.gz caelestia-shell-e4d4c457f867bc6b5b33a8671fdd112425ec4b28.tar.bz2 caelestia-shell-e4d4c457f867bc6b5b33a8671fdd112425ec4b28.zip | |
launcher: allow wallpaper switch when exactly 2 wallpapers (#343)
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/launcher/WallpaperList.qml | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/modules/launcher/WallpaperList.qml b/modules/launcher/WallpaperList.qml index 5979b69..4e2a175 100644 --- a/modules/launcher/WallpaperList.qml +++ b/modules/launcher/WallpaperList.qml @@ -16,22 +16,22 @@ PathView { return 0; const itemWidth = Config.launcher.sizes.wallpaperWidth * 0.8; const max = Config.launcher.maxWallpapers; - if (max * itemWidth > screenWidth) { - const items = Math.floor(screenWidth / itemWidth); - return items > 1 && items % 2 === 0 ? items - 1 : items; - } - return max; + const maxItemsOnScreen = Math.floor(screenWidth / itemWidth); + + const visible = Math.min(maxItemsOnScreen, max, scriptModel.values.length) + if (visible === 2) + return 1 + else if (visible > 1 && visible %2 === 0) + return visible - 1 + return visible; } model: ScriptModel { + id: scriptModel + readonly property string search: root.search.text.split(" ").slice(1).join(" ") - values: { - const list = Wallpapers.query(search); - if (list.length > 1 && list.length % 2 === 0) - list.length -= 1; // Always show odd number - return list; - } + values: Wallpapers.query(search) onValuesChanged: root.currentIndex = search ? 0 : values.findIndex(w => w.path === Wallpapers.actualCurrent) } |