From f1502ade5a50097568183e481344517fda3bb22d Mon Sep 17 00:00:00 2001 From: Claudio Catterina Date: Tue, 13 Aug 2024 08:58:09 +0200 Subject: [PATCH] feat: fallback to selected icon when no album cover available --- src/contents/config/main.xml | 3 +++ src/contents/ui/ConfigGeneral.qml | 7 +++++++ src/contents/ui/main.qml | 10 +++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/contents/config/main.xml b/src/contents/config/main.xml index 09187d2..75b8f04 100644 --- a/src/contents/config/main.xml +++ b/src/contents/config/main.xml @@ -9,6 +9,9 @@ false + + false + 8 diff --git a/src/contents/ui/ConfigGeneral.qml b/src/contents/ui/ConfigGeneral.qml index 7de3954..1b97645 100644 --- a/src/contents/ui/ConfigGeneral.qml +++ b/src/contents/ui/ConfigGeneral.qml @@ -13,6 +13,7 @@ KCM.SimpleKCM { property alias cfg_panelIcon: panelIcon.value property alias cfg_useAlbumCoverAsPanelIcon: useAlbumCoverAsPanelIcon.checked + property alias cfg_fallbackToIconWhenArtNotAvailable: fallbackToIconWhenArtNotAvailable.checked property alias cfg_albumCoverRadius: albumCoverRadius.value property alias cfg_commandsInPanel: commandsInPanel.checked property alias cfg_maxSongWidthInPanel: maxSongWidthInPanel.value @@ -46,6 +47,12 @@ KCM.SimpleKCM { Kirigami.FormData.label: i18n("Use album cover as panel icon") } + CheckBox { + id: fallbackToIconWhenArtNotAvailable + enabled: useAlbumCoverAsPanelIcon.checked + Kirigami.FormData.label: i18n("Fallback to icon if cover is not available") + } + Slider { Layout.preferredWidth: 10 * Kirigami.Units.gridUnit enabled: useAlbumCoverAsPanelIcon.checked diff --git a/src/contents/ui/main.qml b/src/contents/ui/main.qml index 69613f2..d6350fe 100644 --- a/src/contents/ui/main.qml +++ b/src/contents/ui/main.qml @@ -102,7 +102,15 @@ PlasmoidItem { icon: plasmoid.configuration.panelIcon imageUrl: player.artUrl imageRadius: plasmoid.configuration.albumCoverRadius - type: plasmoid.configuration.useAlbumCoverAsPanelIcon ? PanelIcon.Type.Image: PanelIcon.Type.Icon + type: { + if (!plasmoid.configuration.useAlbumCoverAsPanelIcon) { + return PanelIcon.Type.Icon; + } + if (plasmoid.configuration.fallbackToIconWhenArtNotAvailable && !player.artUrl) { + return PanelIcon.Type.Icon; + } + return PanelIcon.Type.Image; + } Layout.rightMargin: Kirigami.Units.smallSpacing * 2 }