From 1a398d9fdb8d7d996f4359ca3556fd6b8a1b1f5d Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Wed, 16 Apr 2025 21:22:33 -0400 Subject: [PATCH] wallpaperselector: Fix delegate dimensions and icon color The previews in the delegates pop outside of the delegate itself. Fix this, and do some refactoring to simplify the code. Also fix an issue with the "+" delegate not being white. --- .../qml/homescreen/WallpaperSelector.qml | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/components/mobileshell/qml/homescreen/WallpaperSelector.qml b/components/mobileshell/qml/homescreen/WallpaperSelector.qml index c11f6182..8bee788e 100644 --- a/components/mobileshell/qml/homescreen/WallpaperSelector.qml +++ b/components/mobileshell/qml/homescreen/WallpaperSelector.qml @@ -41,12 +41,12 @@ Controls.Drawer { anchors.leftMargin: imageWallpaperDrawer.leftMargin anchors.rightMargin: imageWallpaperDrawer.rightMargin anchors.bottomMargin: imageWallpaperDrawer.bottomMargin + orientation: imageWallpaperDrawer.horizontal ? ListView.Vertical : ListView.Horizontal keyNavigationEnabled: true highlightFollowsCurrentItem: true snapMode: ListView.SnapToItem model: imageWallpaper.wallpaperModel - // onCountChanged: currentIndex = Math.min(model.indexOf(configDialog.wallpaperConfiguration["Image"]), model.rowCount()-1) headerPositioning: ListView.InlineHeader header: Controls.ItemDelegate { @@ -60,10 +60,8 @@ Controls.Drawer { bottomPadding: padding background: Rectangle { + radius: Kirigami.Units.cornerRadius color: Qt.rgba(255, 255, 255, (openSettings.down || openSettings.highlighted) ? 0.3 : 0.2) - radius: Kirigami.Units.gridUnit / 4 - anchors.fill: parent - anchors.margins: Kirigami.Units.gridUnit / 4 } contentItem: Item { @@ -72,6 +70,7 @@ Controls.Drawer { implicitHeight: Kirigami.Units.iconSizes.large implicitWidth: Kirigami.Units.iconSizes.large source: 'list-add' + color: 'white' } } @@ -80,13 +79,18 @@ Controls.Drawer { } delegate: Controls.ItemDelegate { + id: delegate + width: imageWallpaperDrawer.horizontal ? parent.width : height * (imageWallpaperDrawer.width / imageWallpaperDrawer.Screen.height) - height: imageWallpaperDrawer.horizontal ? width / (imageWallpaperDrawer.Screen.width / imageWallpaperDrawer.Screen.height) : parent.height - padding: wallpapersView.currentIndex === index ? Kirigami.Units.gridUnit / 4 : Kirigami.Units.gridUnit / 2 - leftPadding: padding - topPadding: padding - rightPadding: padding - bottomPadding: padding + height: imageWallpaperDrawer.horizontal ? width / (imageWallpaperDrawer.Screen.width / imageWallpaperDrawer.Screen.height) : (parent ? parent.height : 0) + padding: Kirigami.Units.largeSpacing - (ListView.isCurrentItem ? Kirigami.Units.smallSpacing : 0) + property real inset: ListView.isCurrentItem ? 0 : Kirigami.Units.smallSpacing + Behavior on inset { + NumberAnimation { + duration: Kirigami.Units.longDuration + easing.type: Easing.InOutQuad + } + } Behavior on padding { NumberAnimation { duration: Kirigami.Units.longDuration @@ -94,6 +98,15 @@ Controls.Drawer { } } + leftPadding: padding + topPadding: padding + rightPadding: padding + bottomPadding: padding + topInset: inset + bottomInset: inset + leftInset: inset + rightInset: inset + property bool isCurrent: WallpaperImagePlugin.WallpaperPlugin.homescreenWallpaperPath == model.path onIsCurrentChanged: { if (isCurrent) { @@ -126,20 +139,10 @@ Controls.Drawer { Keys.onReturnPressed: { clicked(); } - background: Item { - Rectangle { - anchors { - fill: parent - margins: wallpapersView.currentIndex === index ? 0 : Kirigami.Units.gridUnit / 4 - Behavior on margins { - NumberAnimation { - duration: Kirigami.Units.longDuration - easing.type: Easing.InOutQuad - } - } - } - radius: Kirigami.Units.gridUnit / 4 - } + + background: Rectangle { + color: Qt.rgba(255, 255, 255, (delegate.down || delegate.highlighted) ? 0.4 : 0.2) + radius: Kirigami.Units.cornerRadius } } }