diff --git a/app/qml/mpris.qml b/app/qml/mpris.qml --- a/app/qml/mpris.qml +++ b/app/qml/mpris.qml @@ -27,8 +27,21 @@ { id: root property QtObject pluginInterface + property bool muted: false + property int volumeUnmuted title: i18n("Multimedia Controls") + function soundState(volume) + { + if (volume <= 25) { + return "audio-volume-low" + } else if (volume <= 75) { + return "audio-volume-medium" + } else { + return "audio-volume-high" + } + } + Label { id: noPlayersText text: i18n("No players available") @@ -103,13 +116,30 @@ } RowLayout { Layout.fillWidth: true - Label { text: i18n("Volume:") } + Button { + id: muteButton + icon.name: soundState(root.pluginInterface.volume) + onClicked: { + muted = !muted + root.pluginInterface.volume = muted ? 0 : volumeUnmuted + icon.name = muted ? "audio-volume-muted" : soundState(root.pluginInterface.volume) + } + } Slider { - value: root.pluginInterface.volume + id: volumeSlider + value: volumeUnmuted to: 100 + enabled: !muted Layout.fillWidth: true + onValueChanged: { + volumeUnmuted = value + root.pluginInterface.volume = value + muteButton.icon.name = soundState(root.pluginInterface.volume) + } } } Item { Layout.fillHeight: true } } + + Component.onCompleted: volumeUnmuted = root.pluginInterface.volume }