diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-23 16:08:02 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-23 16:08:02 +1000 |
| commit | 66c0d0a15fd9e7ab3c42c3e0f30ead8d793b8352 (patch) | |
| tree | 93d40383a04dcff5b5b62103a944c1126fc9725c /modules/launcher/WallpaperList.qml | |
| parent | dashboard: better visualiser (diff) | |
| download | caelestia-shell-66c0d0a15fd9e7ab3c42c3e0f30ead8d793b8352.tar.gz caelestia-shell-66c0d0a15fd9e7ab3c42c3e0f30ead8d793b8352.tar.bz2 caelestia-shell-66c0d0a15fd9e7ab3c42c3e0f30ead8d793b8352.zip | |
launcher: exact calculation for wallpaper width
Fixes #322
Diffstat (limited to 'modules/launcher/WallpaperList.qml')
| -rw-r--r-- | modules/launcher/WallpaperList.qml | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/modules/launcher/WallpaperList.qml b/modules/launcher/WallpaperList.qml index 9c402ad..e66ae5c 100644 --- a/modules/launcher/WallpaperList.qml +++ b/modules/launcher/WallpaperList.qml @@ -12,18 +12,31 @@ PathView { required property TextField search required property PersistentProperties visibilities + required property var panels + required property var wrapper + + readonly property int itemWidth: Config.launcher.sizes.wallpaperWidth * 0.8 + Appearance.padding.larger * 2 + readonly property int numItems: { - const screenWidth = QsWindow.window?.screen.width * 0.8; - if (!screenWidth) + const screen = QsWindow.window?.screen; + if (!screen) + return 0; + + // Screen width - 4x outer rounding - 2x max side thickness (cause centered) + let outerMargins = Math.max(Config.border.thickness, panels.bar.implicitWidth); + if (panels.popouts.hasCurrent && panels.popouts.currentCenter + panels.popouts.nonAnimHeight / 2 > screen.height - wrapper.implicitHeight - Config.border.thickness * 2) + outerMargins = panels.bar.implicitWidth + panels.popouts.nonAnimWidth; + const maxWidth = screen.width - Config.border.rounding * 4 - outerMargins * 2; + + if (maxWidth <= 0) return 0; - const itemWidth = Config.launcher.sizes.wallpaperWidth * 0.8; - const max = Config.launcher.maxWallpapers; - const maxItemsOnScreen = Math.floor(screenWidth / itemWidth); - const visible = Math.min(maxItemsOnScreen, max, scriptModel.values.length); + const maxItemsOnScreen = Math.floor(maxWidth / itemWidth); + const visible = Math.min(maxItemsOnScreen, Config.launcher.maxWallpapers, scriptModel.values.length); + if (visible === 2) return 1; - else if (visible > 1 && visible % 2 === 0) + if (visible > 1 && visible % 2 === 0) return visible - 1; return visible; } @@ -45,7 +58,7 @@ PathView { Wallpapers.preview(currentItem.modelData.path); } - implicitWidth: Math.min(numItems, count) * (Config.launcher.sizes.wallpaperWidth * 0.8 + Appearance.padding.larger * 2) + implicitWidth: Math.min(numItems, count) * itemWidth pathItemCount: numItems cacheItemCount: 4 |