Skip to content

Commit

Permalink
feat: album cover placeholder
Browse files Browse the repository at this point in the history
Close #17
  • Loading branch information
ccatterina committed Aug 31, 2024
1 parent 476c29e commit e1b41ac
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ To install the widget use one of these methods:
<p align="center">
<img src="./screenshots/screenshot_dark.png" /><img src="./screenshots/screenshot_light.png" />
</p>

## Credits

Album cover placeholder photo by [Brett Jordan](https://unsplash.com/@brett_jordan) on [Unsplash](https://unsplash.com/)
6 changes: 6 additions & 0 deletions src/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,11 @@
<entry name="desktopWidgetBg" type="Int">
<default>1</default>
</entry>
<entry name="useCustomAlbumPlaceholder" type="Bool">
<default>false</default>
</entry>
<entry name="customAlbumPlaceholder" type="String">
<default></default>
</entry>
</group>
</kcfg>
Binary file added src/contents/images/vinyl-disk.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 42 additions & 1 deletion src/contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ KCM.SimpleKCM {
property alias cfg_customFont: fontDialog.fontChosen
property alias cfg_volumeStep: volumeStepSpinbox.value
property alias cfg_desktopWidgetBg: desktopWidgetBackgroundRadio.value
property alias cfg_useCustomAlbumPlaceholder: customAlbumPlaceholderCheckbox.checked
property alias cfg_customAlbumPlaceholder: customAlbumPlaceholderDialog.value


Kirigami.FormLayout {
Expand Down Expand Up @@ -206,6 +208,39 @@ KCM.SimpleKCM {
valueFromText: function(value) { return parseInt(value); }
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Album cover")
}

RowLayout {
Kirigami.FormData.label: i18n("Custom album placeholder:")

CheckBox {
id: customAlbumPlaceholderCheckbox
}

Button {
text: i18n("Choose…")
icon.name: "settings-configure"
enabled: customAlbumPlaceholderCheckbox.checked
onClicked: {
customAlbumPlaceholderDialog.open()
}
}
}

ColumnLayout {
anchors.horizontalCenter: parent.horizontalCenter
visible: customAlbumPlaceholderCheckbox.checked && customAlbumPlaceholderDialog.value
Image {
Layout.preferredWidth: 200
Layout.preferredHeight: 200
Layout.alignment: Qt.AlignHCenter
source: customAlbumPlaceholderDialog.value
}
}

Kirigami.Separator {
Kirigami.FormData.isSection: true
Kirigami.FormData.label: i18n("Background")
Expand Down Expand Up @@ -274,4 +309,10 @@ KCM.SimpleKCM {
fontChosen = selectedFont
}
}
}

QtDialogs.FileDialog {
id: customAlbumPlaceholderDialog
property var value: null
onAccepted: value = selectedFile
}
}
10 changes: 8 additions & 2 deletions src/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,15 @@ PlasmoidItem {
height: width

Image {
readonly property string albumPlaceholder: {
if (plasmoid.configuration.useCustomAlbumPlaceholder) {
return plasmoid.configuration.customAlbumPlaceholder
}
return '../images/vinyl-disk.jpg'
}

anchors.fill: parent
visible: player.artUrl
source: player.artUrl
source: player.artUrl || albumPlaceholder
fillMode: Image.PreserveAspectFit
MouseArea {
id: coverMouseArea
Expand Down

0 comments on commit e1b41ac

Please sign in to comment.