Skip to content

Commit

Permalink
Merge pull request #29 from ccatterina/album-cover-as-toolbar-icon
Browse files Browse the repository at this point in the history
Album cover as toolbar icon
  • Loading branch information
ccatterina authored Nov 30, 2023
2 parents 2c95ad6 + aaf7605 commit a7e0b3b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<entry name="panelIcon" type="string">
<default>view-media-track</default>
</entry>
<entry name="useAlbumCoverAsPanelIcon" type="Bool">
<default>false</default>
</entry>
<entry name="sourceIndex" type="string">
<default>0</default>
</entry>
Expand Down
27 changes: 26 additions & 1 deletion src/contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Item {
height: childrenRect.height

property alias cfg_panelIcon: panelIcon.value
property alias cfg_useAlbumCoverAsPanelIcon: useAlbumCoverAsPanelIcon.checked
property alias cfg_commandsInPanel: commandsInPanel.checked
property alias cfg_maxSongWidthInPanel: maxSongWidthInPanel.value
property alias cfg_sourceIndex: sourceComboBox.currentIndex
Expand All @@ -19,9 +20,25 @@ Item {
anchors.left: parent.left
anchors.right: parent.right

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: "Panel icon"
}

ConfigIcon {
id: panelIcon
Kirigami.FormData.label: i18n("Panel icon:")
Kirigami.FormData.label: i18n("Choose icon:")
}

CheckBox {
id: useAlbumCoverAsPanelIcon
Kirigami.FormData.label: i18n("Album cover:")
text: i18n("Use album cover as panel icon")
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: "Sources"
}

ComboBox {
Expand All @@ -36,6 +53,10 @@ Item {
Kirigami.FormData.label: i18n("Preferred MPRIS2 source:")
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: "Song text"
}
SpinBox {
id: maxSongWidthInPanel
from: 0
Expand All @@ -51,6 +72,10 @@ Item {
Kirigami.FormData.label: i18n("Text scrolling speed:")
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: "Music controls"
}
CheckBox {
id: commandsInPanel
text: "Show music controls in the panel (play/pause/previous/next)"
Expand Down
44 changes: 44 additions & 0 deletions src/contents/ui/PanelIcon.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.core 2.0 as PlasmaCore

Item {
id: root
property string type: "icon"
property var imageUrl: null
property var icon: null
property real size: PlasmaCore.Units.iconSizes.medium

Layout.preferredHeight: size
Layout.preferredWidth: size

onTypeChanged: () => {
if ([ "icon", "image" ].includes(type)) {
console.error("Panel icon type not supported")
}
if (type === "icon" && !icon) {
console.error("Panel icon type is icon but no icon is set")
}
if (type === "image" && !imageUrl) {
console.error("Panel icon type is image but no image url is set")
}
}

PlasmaCore.IconItem {
visible: type === "icon"
id: iconComponent
source: root.icon
implicitHeight: root.size
implicitWidth: root.size
}

Image {
visible: type === "image"
width: root.size
height: root.size
id: imageComponent
source: root.imageUrl
fillMode: Image.PreserveAspectFit
}
}
10 changes: 6 additions & 4 deletions src/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ Item {

anchors.fill: parent

PlasmaCore.IconItem {
source: plasmoid.configuration.panelIcon
implicitHeight: compactRepresentation.controlsSize
implicitWidth: compactRepresentation.controlsSize
PanelIcon {
size: compactRepresentation.controlsSize
icon: plasmoid.configuration.panelIcon
imageUrl: player.artUrl
type: plasmoid.configuration.useAlbumCoverAsPanelIcon ? "image": "icon"
Layout.rightMargin: PlasmaCore.Units.smallSpacing * 2
}

ScrollingText {
Expand Down

0 comments on commit a7e0b3b

Please sign in to comment.