better width handling for wallpaper picker

This commit is contained in:
Zacharias-Brohn
2025-11-13 01:29:35 +01:00
parent f2a7ce6160
commit 374842b321
2 changed files with 32 additions and 2 deletions
+30 -2
View File
@@ -249,17 +249,45 @@ Scope {
readonly property string search: searchInput.text.split(" ").slice(1).join(" ")
values: SearchWallpapers.query( search )
onValuesChanged: wallpaperPickerView.currentIndex = SearchWallpapers.list.findIndex( w => w.path === WallpaperPath.currentWallpaperPath )
}
readonly property int itemWidth: 288 + 10
readonly property int numItems: {
const screen = QsWindow.window?.screen;
if (!screen)
return 0;
// Screen width - 4x outer rounding - 2x max side thickness (cause centered)
const barMargins = 10;
let outerMargins = 0;
const maxWidth = screen.width - (barMargins + outerMargins) * 2;
if (maxWidth <= 0)
return 0;
const maxItemsOnScreen = Math.floor(maxWidth / itemWidth);
const visible = Math.min(maxItemsOnScreen, Config.maxWallpapers, wallpaperModel.values.length);
if (visible === 2)
return 1;
if (visible > 1 && visible % 2 === 0)
return visible - 1;
return visible;
}
Component.onCompleted: currentIndex = SearchWallpapers.list.findIndex( w => w.path === WallpaperPath.currentWallpaperPath )
cacheItemCount: 5
snapMode: PathView.SnapToItem
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
highlightRangeMode: PathView.StrictlyEnforceRange
pathItemCount: 7
pathItemCount: numItems
implicitHeight: 212
implicitWidth: Math.min( wallpaperModel.values.length, 7 ) * 192 + Math.max(0, wallpaperModel.values.length -1) * 10
implicitWidth: Math.min( numItems, count ) * itemWidth
path: Path {
startY: wallpaperPickerView.height / 2