From 66c0d0a15fd9e7ab3c42c3e0f30ead8d793b8352 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 23 Aug 2025 16:08:02 +1000 Subject: launcher: exact calculation for wallpaper width Fixes #322 --- modules/drawers/Panels.qml | 2 +- modules/launcher/Content.qml | 5 +++++ modules/launcher/ContentList.qml | 4 ++++ modules/launcher/WallpaperList.qml | 29 +++++++++++++++++++++-------- modules/launcher/Wrapper.qml | 3 +++ 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/modules/drawers/Panels.qml b/modules/drawers/Panels.qml index d27dca0..0e592df 100644 --- a/modules/drawers/Panels.qml +++ b/modules/drawers/Panels.qml @@ -1,4 +1,3 @@ -import qs.services import qs.config import qs.modules.osd as Osd import qs.modules.notifications as Notifications @@ -64,6 +63,7 @@ Item { id: launcher visibilities: root.visibilities + panels: root anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom diff --git a/modules/launcher/Content.qml b/modules/launcher/Content.qml index 9b0e4e5..a8d8422 100644 --- a/modules/launcher/Content.qml +++ b/modules/launcher/Content.qml @@ -11,7 +11,10 @@ import QtQuick Item { id: root + required property var wrapper required property PersistentProperties visibilities + required property var panels + readonly property int padding: Appearance.padding.large readonly property int rounding: Appearance.rounding.large @@ -34,7 +37,9 @@ Item { ContentList { id: list + wrapper: root.wrapper visibilities: root.visibilities + panels: root.panels search: search padding: root.padding rounding: root.rounding diff --git a/modules/launcher/ContentList.qml b/modules/launcher/ContentList.qml index e363c7b..d426d58 100644 --- a/modules/launcher/ContentList.qml +++ b/modules/launcher/ContentList.qml @@ -11,7 +11,9 @@ import QtQuick.Controls Item { id: root + required property var wrapper required property PersistentProperties visibilities + required property var panels required property TextField search required property int padding required property int rounding @@ -103,6 +105,8 @@ Item { sourceComponent: WallpaperList { search: root.search visibilities: root.visibilities + panels: root.panels + wrapper: root.wrapper } } 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 diff --git a/modules/launcher/Wrapper.qml b/modules/launcher/Wrapper.qml index 41126dd..f1ab672 100644 --- a/modules/launcher/Wrapper.qml +++ b/modules/launcher/Wrapper.qml @@ -6,6 +6,7 @@ Item { id: root required property PersistentProperties visibilities + required property var panels visible: height > 0 implicitHeight: 0 @@ -50,6 +51,8 @@ Item { Content { id: content + wrapper: root visibilities: root.visibilities + panels: root.panels } } -- cgit v1.2.3-freya