From 3b31c2e1c8c1c9a17f7d37c469f6f0cf42a95725 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Mon, 19 May 2025 23:48:06 +0800 Subject: launcher: limit wallpapers to screen width --- modules/launcher/WallpaperList.qml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/launcher/WallpaperList.qml b/modules/launcher/WallpaperList.qml index 9a7c552..8c3afb2 100644 --- a/modules/launcher/WallpaperList.qml +++ b/modules/launcher/WallpaperList.qml @@ -10,6 +10,18 @@ PathView { required property TextField search required property PersistentProperties visibilities + readonly property int numItems: { + const screenWidth = QsWindow.window?.screen.width - BorderConfig.thickness * 2 - BorderConfig.rounding * 4 - Appearance.padding.large * 2; + if (!screenWidth) + return 0; + const itemWidth = LauncherConfig.sizes.wallpaperWidth * 0.8; + const max = LauncherConfig.maxWallpapers; + if (max * itemWidth > screenWidth) { + const items = Math.floor(screenWidth / itemWidth); + return items > 1 && items % 2 === 0 ? items - 1 : items; + } + return max; + } model: ScriptModel { readonly property string search: root.search.text.split(" ").slice(1).join(" ") @@ -31,8 +43,8 @@ PathView { Wallpapers.preview(currentItem.modelData.path); } - implicitWidth: Math.min(LauncherConfig.maxWallpapers, count) * (LauncherConfig.sizes.wallpaperWidth * 0.8 + Appearance.padding.larger * 2) - pathItemCount: LauncherConfig.maxWallpapers + implicitWidth: Math.min(numItems, count) * (LauncherConfig.sizes.wallpaperWidth * 0.8 + Appearance.padding.larger * 2) + pathItemCount: numItems cacheItemCount: 4 snapMode: PathView.SnapToItem -- cgit v1.2.3-freya