controlcenter: lazyloading wallpaper

This commit is contained in:
ATMDA 2025-11-16 13:21:59 -05:00
parent 0e1be8126a
commit f77323b136

View file

@ -1895,34 +1895,47 @@ RowLayout {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: Appearance.spacing.large Layout.topMargin: Appearance.spacing.large
Layout.preferredHeight: wallpaperGrid.Layout.preferredHeight Layout.preferredHeight: wallpaperLoader.item ? wallpaperLoader.item.layoutPreferredHeight : 0
GridView { Loader {
id: wallpaperGrid id: wallpaperLoader
anchors.fill: parent anchors.fill: parent
asynchronous: true
active: {
// Lazy load: only activate when right pane is loaded
// This defers heavy wallpaper list loading until the right pane is visible
return rightAppearanceLoader.item !== null;
}
readonly property int minCellWidth: 200 + Appearance.spacing.normal sourceComponent: Item {
readonly property int columnsCount: Math.max(1, Math.floor(parent.width / minCellWidth)) property alias layoutPreferredHeight: wallpaperGrid.layoutPreferredHeight
Layout.preferredHeight: Math.ceil(count / columnsCount) * cellHeight GridView {
height: Layout.preferredHeight id: wallpaperGrid
anchors.fill: parent
// Distribute width evenly across columns readonly property int minCellWidth: 200 + Appearance.spacing.normal
cellWidth: width / columnsCount readonly property int columnsCount: Math.max(1, Math.floor(parent.width / minCellWidth))
cellHeight: 140 + Appearance.spacing.normal
leftMargin: 0 readonly property int layoutPreferredHeight: Math.ceil(count / columnsCount) * cellHeight
rightMargin: 0 height: layoutPreferredHeight
topMargin: 0
bottomMargin: 0
model: Wallpapers.list // Distribute width evenly across columns
cellWidth: width / columnsCount
cellHeight: 140 + Appearance.spacing.normal
// Disable GridView's own scrolling - let parent handle it leftMargin: 0
interactive: false rightMargin: 0
topMargin: 0
bottomMargin: 0
// Enable caching for better performance model: Wallpapers.list
cacheBuffer: cellHeight * 2
// Disable GridView's own scrolling - let parent handle it
interactive: false
// Enable caching for better performance
cacheBuffer: cellHeight * 2
delegate: Item { delegate: Item {
required property var modelData required property var modelData
@ -2141,7 +2154,9 @@ RowLayout {
} }
} }
} }
} }
}
}
} }
} }
} }