From 38338042c02c501945decdbfbf66819d7c85d5e2 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Sat, 25 Dec 2021 10:30:32 +0800 Subject: [PATCH] applets/mediacontroller: Fix incorrect scale factor of backgroundImage The scale factor was incorrect because it always compared with 1, which caused the background image not being resized properly when height > width. This commit uses the same scale factor in ToolTipInstance.qml, so the scale factor is correct again. --- .../mediacontroller/contents/ui/ExpandedRepresentation.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/applets/mediacontroller/contents/ui/ExpandedRepresentation.qml b/applets/mediacontroller/contents/ui/ExpandedRepresentation.qml index 2d582688e..644fbf9a7 100644 --- a/applets/mediacontroller/contents/ui/ExpandedRepresentation.qml +++ b/applets/mediacontroller/contents/ui/ExpandedRepresentation.qml @@ -124,6 +124,7 @@ PlasmaExtras.Representation { ShaderEffect { id: backgroundImage + property real scaleFactor: 1.0 property Image source: albumArt anchors.centerIn: parent @@ -153,8 +154,9 @@ PlasmaExtras.Representation { when: plasmoid.expanded && backgroundImage.visible && albumArt.paintedWidth > 0 PropertyChanges { target: backgroundImage - width: parent.width * Math.max(1, source.paintedWidth / source.paintedHeight) - height: parent.width * Math.max(1, source.paintedHeight / source.paintedWidth) + scaleFactor: Math.max(parent.width / source.paintedWidth, parent.height / source.paintedHeight) + width: Math.round(source.paintedWidth * scaleFactor) + height: Math.round(source.paintedHeight * scaleFactor) } } }