feat: add optional label artwork mode

This commit is contained in:
2026-05-30 11:08:56 +00:00
parent d62c81762b
commit b88c2ba3c5
4 changed files with 95 additions and 43 deletions
+4
View File
@@ -38,6 +38,10 @@
<default><![CDATA[NOW <default><![CDATA[NOW
PLAYING]]></default> PLAYING]]></default>
</entry> </entry>
<entry name="useLabelArtwork" type="Bool">
<label>Show track image when available</label>
<default>false</default>
</entry>
<entry name="backgroundStyle" type="String"> <entry name="backgroundStyle" type="String">
<label>Background style</label> <label>Background style</label>
<default>custom</default> <default>custom</default>
+38 -4
View File
@@ -14,6 +14,7 @@ MouseArea {
property string configuredLabelVisibilityMode: "auto" property string configuredLabelVisibilityMode: "auto"
property string configuredLabelPlacement: "left" property string configuredLabelPlacement: "left"
property string configuredLabelText: "NOW\nPLAYING" property string configuredLabelText: "NOW\nPLAYING"
property bool configuredUseLabelArtwork: false
property string configuredBackgroundStyle: "custom" property string configuredBackgroundStyle: "custom"
property string configuredBackgroundColor: "transparent" property string configuredBackgroundColor: "transparent"
property int configuredBackgroundRadius: 0 property int configuredBackgroundRadius: 0
@@ -82,7 +83,7 @@ MouseArea {
HoverHandler { HoverHandler {
id: rootHoverHandler id: rootHoverHandler
margin: 12 margin: 60
} }
Timer { Timer {
@@ -143,17 +144,46 @@ MouseArea {
Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight
Layout.fillWidth: true Layout.fillWidth: true
spacing: mediaControlsMouseArea.effectiveLabelVerticalSpacing
visible: mediaControlsMouseArea.nowPlayingLabelsVisible visible: mediaControlsMouseArea.nowPlayingLabelsVisible
Item {
id: labelContent
readonly property bool artworkReady: mediaControlsMouseArea.configuredUseLabelArtwork && artworkImage.status === Image.Ready && artworkImage.source.toString().length > 0
Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight
Layout.fillWidth: true
clip: artworkReady
implicitHeight: artworkReady ? mediaControlsMouseArea.labelRailWidth : labelTextColumn.implicitHeight
Image {
id: artworkImage
anchors.fill: parent
asynchronous: true
cache: true
fillMode: Image.PreserveAspectCrop
source: mediaControlsMouseArea.configuredUseLabelArtwork ? player.artUrl : ""
sourceSize.width: mediaControlsMouseArea.labelRailWidth
sourceSize.height: mediaControlsMouseArea.labelRailWidth
visible: labelContent.artworkReady
}
Column {
id: labelTextColumn
anchors.left: parent.left
anchors.right: parent.right
spacing: mediaControlsMouseArea.effectiveLabelVerticalSpacing
visible: !labelContent.artworkReady
Repeater { Repeater {
model: mediaControlsMouseArea.effectiveLabelLines model: mediaControlsMouseArea.effectiveLabelLines
delegate: ShadowedLabel { delegate: ShadowedLabel {
required property string modelData required property string modelData
Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight width: labelTextColumn.width
Layout.fillWidth: true
shadowEnabled: mediaControlsMouseArea.configuredTextShadowEnabled shadowEnabled: mediaControlsMouseArea.configuredTextShadowEnabled
text: modelData text: modelData
lineHeight: 0.8 lineHeight: 0.8
@@ -168,6 +198,10 @@ MouseArea {
} }
}
}
RowLayout { RowLayout {
id: mediaControls id: mediaControls
+37 -27
View File
@@ -16,6 +16,7 @@ KCM.SimpleKCM {
property string cfg_labelVisibilityMode property string cfg_labelVisibilityMode
property string cfg_labelPlacement property string cfg_labelPlacement
property alias cfg_labelText: labelTextArea.text property alias cfg_labelText: labelTextArea.text
property alias cfg_useLabelArtwork: useLabelArtworkCheckBox.checked
property string cfg_backgroundStyle property string cfg_backgroundStyle
property alias cfg_backgroundColor: backgroundColorField.text property alias cfg_backgroundColor: backgroundColorField.text
property alias cfg_backgroundRadius: backgroundRadiusSpinBox.value property alias cfg_backgroundRadius: backgroundRadiusSpinBox.value
@@ -67,33 +68,6 @@ KCM.SimpleKCM {
return options[resolvedIndex].value; return options[resolvedIndex].value;
} }
component SectionHeader: Item {
required property string title
Kirigami.FormData.isSection: true
implicitHeight: sectionLayout.implicitHeight
ColumnLayout {
id: sectionLayout
anchors.left: parent.left
anchors.right: parent.right
spacing: Kirigami.Units.smallSpacing
QQC2.Label {
text: parent.parent.title
font.bold: true
}
Rectangle {
Layout.fillWidth: true
implicitHeight: 1
color: Kirigami.Theme.textColor
opacity: 0.25
}
}
}
onCfg_fontFamilyChanged: { onCfg_fontFamilyChanged: {
const index = availableFonts.indexOf(cfg_fontFamily); const index = availableFonts.indexOf(cfg_fontFamily);
if (index >= 0 && fontFamilyComboBox.currentIndex !== index) if (index >= 0 && fontFamilyComboBox.currentIndex !== index)
@@ -239,6 +213,13 @@ KCM.SimpleKCM {
onActivated: configRoot.cfg_labelPlacement = currentValue onActivated: configRoot.cfg_labelPlacement = currentValue
} }
QQC2.CheckBox {
id: useLabelArtworkCheckBox
Kirigami.FormData.label: i18n("Label image:")
text: i18n("Show track image when available")
}
QQC2.TextArea { QQC2.TextArea {
id: labelTextArea id: labelTextArea
@@ -327,4 +308,33 @@ KCM.SimpleKCM {
onAccepted: configRoot.cfg_foregroundColor = selectedColor.toString() onAccepted: configRoot.cfg_foregroundColor = selectedColor.toString()
} }
component SectionHeader: Item {
required property string title
Kirigami.FormData.isSection: true
implicitHeight: sectionLayout.implicitHeight
ColumnLayout {
id: sectionLayout
anchors.left: parent.left
anchors.right: parent.right
spacing: Kirigami.Units.smallSpacing
QQC2.Label {
text: parent.parent.title
font.bold: true
}
Rectangle {
Layout.fillWidth: true
implicitHeight: 1
color: Kirigami.Theme.textColor
opacity: 0.25
}
}
}
} }
+4
View File
@@ -27,6 +27,8 @@ PlasmoidItem {
// qmllint disable missing-property // qmllint disable missing-property
property string configuredLabelText: plasmoid.configuration.labelText property string configuredLabelText: plasmoid.configuration.labelText
// qmllint disable missing-property // qmllint disable missing-property
property bool configuredUseLabelArtwork: plasmoid.configuration.useLabelArtwork
// qmllint disable missing-property
property string configuredBackgroundStyle: plasmoid.configuration.backgroundStyle property string configuredBackgroundStyle: plasmoid.configuration.backgroundStyle
// qmllint disable missing-property // qmllint disable missing-property
property string configuredBackgroundColor: plasmoid.configuration.backgroundColor property string configuredBackgroundColor: plasmoid.configuration.backgroundColor
@@ -81,6 +83,7 @@ PlasmoidItem {
configuredLabelVisibilityMode: root.configuredLabelVisibilityMode configuredLabelVisibilityMode: root.configuredLabelVisibilityMode
configuredLabelPlacement: root.configuredLabelPlacement configuredLabelPlacement: root.configuredLabelPlacement
configuredLabelText: root.configuredLabelText configuredLabelText: root.configuredLabelText
configuredUseLabelArtwork: root.configuredUseLabelArtwork
configuredBackgroundStyle: root.configuredBackgroundStyle configuredBackgroundStyle: root.configuredBackgroundStyle
configuredBackgroundColor: root.configuredBackgroundColor configuredBackgroundColor: root.configuredBackgroundColor
configuredBackgroundRadius: root.configuredBackgroundRadius configuredBackgroundRadius: root.configuredBackgroundRadius
@@ -107,6 +110,7 @@ PlasmoidItem {
configuredLabelVisibilityMode: root.configuredLabelVisibilityMode configuredLabelVisibilityMode: root.configuredLabelVisibilityMode
configuredLabelPlacement: root.configuredLabelPlacement configuredLabelPlacement: root.configuredLabelPlacement
configuredLabelText: root.configuredLabelText configuredLabelText: root.configuredLabelText
configuredUseLabelArtwork: root.configuredUseLabelArtwork
configuredBackgroundStyle: root.configuredBackgroundStyle configuredBackgroundStyle: root.configuredBackgroundStyle
configuredBackgroundColor: root.configuredBackgroundColor configuredBackgroundColor: root.configuredBackgroundColor
configuredBackgroundRadius: root.configuredBackgroundRadius configuredBackgroundRadius: root.configuredBackgroundRadius