better width handling for wallpaper picker
This commit is contained in:
@@ -9,6 +9,7 @@ Singleton {
|
||||
property alias baseBgColor: adapter.baseBgColor
|
||||
property alias accentColor: adapter.accentColor
|
||||
property alias wallpaperPath: adapter.wallpaperPath
|
||||
property alias maxWallpapers: adapter.maxWallpapers
|
||||
|
||||
FileView {
|
||||
id: root
|
||||
@@ -27,6 +28,7 @@ Singleton {
|
||||
property string wallpaperPath: Quickshell.env("HOME") + "/Pictures/Wallpapers"
|
||||
property string baseBgColor: "#801a1a1a"
|
||||
property AccentColor accentColor: AccentColor {}
|
||||
property int maxWallpapers: 7
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user