Skip to content

Commit e3d8ea7

Browse files
committed
feature: add option to change sound effect
#33
1 parent 77caaac commit e3d8ea7

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

package/contents/config/main.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,9 @@
4545
<min>0.0</min>
4646
<max>1.0</max>
4747
</entry>
48+
<entry name="customSoundPath" type="String">
49+
<label>Path to custom sound effect</label>
50+
<default></default>
51+
</entry>
4852
</group>
4953
</kcfg>

package/contents/ui/config/configSound.qml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import QtQuick
22
import QtQuick.Controls
33
import QtQuick.Layouts
4+
import QtQuick.Dialogs
45
import org.kde.kirigami as Kirigami
56
import QtMultimedia
67

78
Item {
89
id: soundPage;
910

1011
property double cfg_volume: plasmoid.configuration.volume
12+
property string cfg_customSoundPath: plasmoid.configuration.customSoundPath
1113

1214
MediaPlayer {
1315
id: testSound;
14-
source: Qt.resolvedUrl("../../effects/meow.mp3");
16+
source: cfg_customSoundPath ? cfg_customSoundPath : Qt.resolvedUrl("../../effects/meow.mp3");
1517
audioOutput: AudioOutput {
1618
volume: soundPage.cfg_volume
1719
}
@@ -59,6 +61,40 @@ Item {
5961
}
6062
}
6163
}
64+
65+
RowLayout {
66+
Kirigami.FormData.label: i18n("Custom sound:")
67+
Layout.fillWidth: true
68+
69+
TextField {
70+
id: soundPathField
71+
text: soundPage.cfg_customSoundPath
72+
placeholderText: i18n("Path to custom sound file")
73+
Layout.fillWidth: true
74+
readOnly: true
75+
}
76+
77+
Button {
78+
text: i18n("Browse...")
79+
icon.name: "folder-open"
80+
onClicked: soundFileDialog.open()
81+
}
82+
83+
Button {
84+
text: i18n("Reset")
85+
icon.name: "edit-undo"
86+
enabled: soundPage.cfg_customSoundPath !== ""
87+
onClicked: soundPage.cfg_customSoundPath = ""
88+
}
89+
}
6290
}
6391
}
92+
93+
FileDialog {
94+
id: soundFileDialog
95+
title: i18n("Choose a sound file")
96+
currentFolder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
97+
nameFilters: [i18n("Audio files (*.mp3 *.wav *.ogg)"), i18n("All files (*)")]
98+
onAccepted: soundPage.cfg_customSoundPath = selectedFile
99+
}
64100
}

package/contents/ui/main.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PlasmoidItem {
3434

3535
MediaPlayer {
3636
id: meowSound
37-
source: Qt.resolvedUrl("../effects/meow.mp3")
37+
source: plasmoid.configuration.customSoundPath ? plasmoid.configuration.customSoundPath : Qt.resolvedUrl("../effects/meow.mp3")
3838
audioOutput: AudioOutput {
3939
volume: root.volume
4040
}

package/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"KPlugin": {
44
"Id": "xyz.attacktive.nyan-wanderer",
55
"Name": "Nyan Wanderer",
6-
"Version": "1.1.3",
6+
"Version": "1.1.4",
77
"Description": "A cute Nyan Cat that wanders around your desktop",
88
"Category": "Fun and Games",
99
"Icon": "animal-symbolic",

0 commit comments

Comments
 (0)