Skip to content

Commit

Permalink
feat: fallback to selected icon when no album cover available
Browse files Browse the repository at this point in the history
  • Loading branch information
ccatterina committed Aug 13, 2024
1 parent 8165d0f commit f1502ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<entry name="useAlbumCoverAsPanelIcon" type="Bool">
<default>false</default>
</entry>
<entry name="fallbackToIconWhenArtNotAvailable" type="Bool">
<default>false</default>
</entry>
<entry name="albumCoverRadius" type="Int">
<default>8</default>
</entry>
Expand Down
7 changes: 7 additions & 0 deletions src/contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit f1502ad

Please sign in to comment.