Commit 1df3476c authored by Sebastian Goth's avatar Sebastian Goth Committed by Nate Graham

Add options for OSD feedback

Summary:
Extend configuration knobs for visual feedback by adding separate ones
for output volume, input volume and mute state.

BUG: 363983
FIXED-IN: 5.19.0

Reviewers: #vdg, #plasma, broulik, ngraham, drosca, cblack

Reviewed By: #vdg, #plasma, ngraham, cblack

Subscribers: The-Feren-OS-Dev, cblack, drosca, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28281
parent 29566a86
......@@ -15,6 +15,18 @@
<entry name="volumeFeedback" type="Bool">
<default>true</default>
</entry>
<entry name="volumeOsd" type="Bool">
<label>Whether to show a popup when the volume changes</label>
<default>true</default>
</entry>
<entry name="muteOsd" type="Bool">
<label>Whether to show a popup when mute state changes</label>
<default>true</default>
</entry>
<entry name="micOsd" type="Bool">
<label>Whether to show a popup when microphone volume changes</label>
<default>true</default>
</entry>
<entry name="outputChangeOsd" type="Bool">
<label>Whether to show a popup when the default output device changes (e.g. plugging in a headset)</label>
<default>true</default>
......
......@@ -29,6 +29,9 @@ import org.kde.plasma.private.volume 0.1
Kirigami.FormLayout {
property alias cfg_volumeStep: volumeStep.value
property alias cfg_volumeFeedback: volumeFeedback.checked
property alias cfg_volumeOsd: volumeOsd.checked
property alias cfg_micOsd: micOsd.checked
property alias cfg_muteOsd: muteOsd.checked
property alias cfg_outputChangeOsd: outputChangeOsd.checked
VolumeFeedback {
......@@ -62,14 +65,34 @@ Kirigami.FormLayout {
QQC2.CheckBox {
id: volumeFeedback
Kirigami.FormData.label: i18n("Feedback:")
Kirigami.FormData.label: i18n("Play audio feedback for changes to:")
text: i18n("Play sound when volume changes")
text: i18n("Audio volume")
enabled: feedback.valid
}
Item {
Kirigami.FormData.isSection: true
}
QQC2.CheckBox {
id: volumeOsd
Kirigami.FormData.label: i18n("Show visual feedback for changes to:")
text: i18n("Audio volume")
}
QQC2.CheckBox {
id: micOsd
text: i18n("Microphone sensitivity")
}
QQC2.CheckBox {
id: muteOsd
text: i18n("Mute state")
}
QQC2.CheckBox {
id: outputChangeOsd
text: i18n("Display notification when default output device changes")
text: i18n("Default output device")
}
}
......@@ -101,7 +101,7 @@ Item {
var percent = volumePercent(volume, currentMaxVolumeValue);
paSinkModel.preferredSink.muted = percent == 0;
paSinkModel.preferredSink.volume = volume;
osd.show(percent);
osd.showVolume(percent);
playFeedback();
}
......@@ -113,7 +113,7 @@ Item {
var percent = volumePercent(volume, currentMaxVolumeValue);
paSinkModel.preferredSink.muted = percent == 0;
paSinkModel.preferredSink.volume = volume;
osd.show(percent);
osd.showVolume(percent);
playFeedback();
}
......@@ -124,13 +124,13 @@ Item {
var toMute = !paSinkModel.preferredSink.muted;
if (toMute) {
enableGlobalMute();
osd.show(0);
osd.showMute(0);
} else {
if (globalMute) {
disableGlobalMute();
}
paSinkModel.preferredSink.muted = toMute;
osd.show(volumePercent(paSinkModel.preferredSink.volume, currentMaxVolumeValue));
osd.showMute(volumePercent(paSinkModel.preferredSink.volume, currentMaxVolumeValue));
playFeedback();
}
}
......@@ -143,7 +143,7 @@ Item {
var percent = volumePercent(volume, currentMaxVolumeValue);
paSourceModel.defaultSource.muted = percent == 0;
paSourceModel.defaultSource.volume = volume;
osd.showMicrophone(percent);
osd.showMic(percent);
}
function decreaseMicrophoneVolume() {
......@@ -154,7 +154,7 @@ Item {
var percent = volumePercent(volume, currentMaxVolumeValue);
paSourceModel.defaultSource.muted = percent == 0;
paSourceModel.defaultSource.volume = volume;
osd.showMicrophone(percent);
osd.showMic(percent);
}
function muteMicrophone() {
......@@ -163,7 +163,7 @@ Item {
}
var toMute = !paSourceModel.defaultSource.muted;
paSourceModel.defaultSource.muted = toMute;
osd.showMicrophone(toMute? 0 : volumePercent(paSourceModel.defaultSource.volume, currentMaxVolumeValue));
osd.showMicMute(toMute? 0 : volumePercent(paSourceModel.defaultSource.volume, currentMaxVolumeValue));
}
function playFeedback(sinkIndex) {
......@@ -176,6 +176,7 @@ Item {
feedback.play(sinkIndex);
}
function enableGlobalMute() {
var role = paSinkModel.role("Muted");
var rowCount = paSinkModel.rowCount();
......@@ -358,6 +359,30 @@ Item {
VolumeOSD {
id: osd
function showVolume(text) {
if (!main.Plasmoid.configuration.volumeOsd)
return
show(text)
}
function showMute(text) {
if (!main.Plasmoid.configuration.muteOsd)
return
show(text)
}
function showMic(text) {
if (!main.Plasmoid.configuration.micOsd)
return
showMicrophone(text)
}
function showMicMute(text) {
if (!main.Plasmoid.configuration.muteOsd)
return
showMicrophone(text)
}
}
VolumeFeedback {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment