From bedf853f6357b2e2c334e8cdf90fb311927d6653 Mon Sep 17 00:00:00 2001 From: zhangkun Date: Mon, 9 Dec 2024 10:46:29 +0800 Subject: [PATCH] feat: wallpaper module optimization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 异步加载图片 - 居中布局 pms: TASK-368711 --- .../qml/WallpaperSelectView.qml | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/plugin-personalization/qml/WallpaperSelectView.qml b/src/plugin-personalization/qml/WallpaperSelectView.qml index 4c687b970e..8dfc9b2384 100644 --- a/src/plugin-personalization/qml/WallpaperSelectView.qml +++ b/src/plugin-personalization/qml/WallpaperSelectView.qml @@ -66,10 +66,26 @@ ColumnLayout { } } + Flow { + id: layout + property int lineCount: Math.floor((parent.width + imageSpacing) / (imageRectW + imageSpacing)) + width: lineCount * (imageRectW + imageSpacing) - imageSpacing + spacing: imageSpacing + bottomPadding: imageSpacing + anchors.horizontalCenter: parent.horizontalCenter + + move: Transition { + } + + Repeater { + model: sortedModel + } + } + D.SortFilterModel { id: sortedModel model: root.model - property int maxCount: Math.floor((layout.width + imageSpacing) / (imageRectW + imageSpacing)) * 2 + property int maxCount: layout.lineCount * 2 lessThan: function(left, right) { return left.index < right.index } @@ -104,6 +120,7 @@ ColumnLayout { height: 2 / Screen.devicePixelRatio source: model.url fillMode: Image.Stretch + asynchronous: true } Image { @@ -200,18 +217,5 @@ ColumnLayout { } } } - Flow { - id: layout - width: parent.width - spacing: imageSpacing - bottomPadding: imageSpacing - - move: Transition { - } - - Repeater { - model: sortedModel - } - } } }