Skip to content

Commit

Permalink
Merge pull request #87 from TheSnowfield/main
Browse files Browse the repository at this point in the history
feat: radius with album image
  • Loading branch information
ccatterina committed Apr 4, 2024
2 parents dbd7d45 + 48a363b commit 87fbcf4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
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="albumCoverRadius" type="Int">
<default>8</default>
</entry>
<entry name="sourceIndex" type="string">
<default>0</default>
</entry>
Expand Down
11 changes: 10 additions & 1 deletion src/contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.kde.kcmutils as KCM
KCM.SimpleKCM {
property alias cfg_panelIcon: panelIcon.value
property alias cfg_useAlbumCoverAsPanelIcon: useAlbumCoverAsPanelIcon.checked
property alias cfg_albumCoverRadius: albumCoverRadius.value
property alias cfg_commandsInPanel: commandsInPanel.checked
property alias cfg_maxSongWidthInPanel: maxSongWidthInPanel.value
property alias cfg_sourceIndex: sourceComboBox.currentIndex
Expand All @@ -33,6 +34,14 @@ KCM.SimpleKCM {
text: i18n("Use album cover as panel icon")
}

Slider {
id: albumCoverRadius
from: 0
to: 25
stepSize: 2
Kirigami.FormData.label: i18n("Album cover radius:")
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: "Sources"
Expand Down Expand Up @@ -119,4 +128,4 @@ KCM.SimpleKCM {
Kirigami.FormData.label: i18n("Show controls:")
}
}
}
}
20 changes: 18 additions & 2 deletions src/contents/ui/PanelIcon.qml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import Qt5Compat.GraphicalEffects
import org.kde.plasma.components as PlasmaComponents3
import org.kde.kirigami as Kirigami


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

Expand Down Expand Up @@ -40,7 +41,22 @@ Item {
width: root.size
height: root.size
id: imageComponent
anchors.fill: parent
source: root.imageUrl
fillMode: Image.PreserveAspectFit

// enables round corners while the radius is set
// ref: https://stackoverflow.com/questions/6090740/image-rounded-corners-in-qml
layer.enabled: imageRadius > 0
layer.effect: OpacityMask {
maskSource: Item {
width: imageComponent.width
height: imageComponent.height
Rectangle {
anchors.fill: parent
radius: imageRadius
}
}
}
}
}
}
1 change: 1 addition & 0 deletions src/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ PlasmoidItem {
size: compact.controlsSize
icon: plasmoid.configuration.panelIcon
imageUrl: player.artUrl
imageRadius: plasmoid.configuration.albumCoverRadius
type: plasmoid.configuration.useAlbumCoverAsPanelIcon ? "image": "icon"
Layout.rightMargin: Kirigami.Units.smallSpacing * 2
}
Expand Down

0 comments on commit 87fbcf4

Please sign in to comment.