Commit 893ee005 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Show OSD when default output changes

When the default output changes because a device is plugged in or a Bluetooth headset is connected,
show an OSD so the user knows when/that the device is ready to use.

Differential Revision: https://phabricator.kde.org/D12083
parent d6d7090c
......@@ -35,3 +35,37 @@ function name(volume, muted, prefix) {
}
return icon;
}
function formFactorIcon(formFactor) {
switch(formFactor) {
case "internal":
return "audio-card";
case "speaker":
return "audio-speakers-symbolic";
case "phone":
return "phone";
case "handset":
return "phone";
case "tv":
return "video-television";
case "webcam":
return "camera-web";
case "microphone":
return "audio-input-microphone";
case "headset":
return "audio-headset";
case "headphone":
return "audio-headphones";
case "hands-free":
return "hands-free";
case "car":
return "car";
case "hifi":
return "hifi";
case "computer":
return "computer";
case "portable":
return "portable";
}
return "";
}
......@@ -15,6 +15,10 @@
<entry name="volumeFeedback" type="Bool">
<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>
</entry>
</group>
</kcfg>
......@@ -28,6 +28,7 @@ Item {
property alias cfg_maximumVolume: maximumVolume.value
property alias cfg_volumeStep: volumeStep.value
property alias cfg_volumeFeedback: volumeFeedback.checked
property alias cfg_outputChangeOsd: outputChangeOsd.checked
ColumnLayout {
Layout.fillWidth: true
......@@ -80,6 +81,11 @@ Item {
text: i18n("Volume feedback")
enabled: feedback.valid
}
CheckBox {
id: outputChangeOsd
text: i18n("Visual feedback when default output device changes")
}
}
}
}
......
......@@ -20,6 +20,8 @@
import QtQuick 2.0
import "../code/icon.js" as Icon
ListItemBase {
readonly property var currentPort: Ports[ActivePortIndex]
property bool onlyOne: false
......@@ -37,37 +39,5 @@ ListItemBase {
}
}
labelOpacity: onlyOne ? 1 : 0.6
icon: {
switch(FormFactor) {
case "internal":
return "audio-card";
case "speaker":
return "audio-speakers-symbolic";
case "phone":
return "phone";
case "handset":
return "phone";
case "tv":
return "video-television";
case "webcam":
return "camera-web";
case "microphone":
return "audio-input-microphone";
case "headset":
return "audio-headset";
case "headphone":
return "audio-headphones";
case "hands-free":
return "hands-free"; break;
case "car":
return "car"; break;
case "hifi":
return "hifi"; break;
case "computer":
return "computer"; break;
case "portable":
return "portable"; break;
}
return IconName;
}
icon: Icon.formFactorIcon(FormFactor) || IconName
}
......@@ -149,6 +149,26 @@ Item {
SinkModel {
id: paSinkModel
property bool initalDefaultSinkIsSet: false
onDefaultSinkChanged: {
if (!defaultSink || !plasmoid.configuration.outputChangeOsd) {
return;
}
// avoid showing a OSD on startup
if (!initalDefaultSinkIsSet) {
initalDefaultSinkIsSet = true;
return;
}
var icon = Icon.formFactorIcon(defaultSink.formFactor);
if (!icon) {
icon = Icon.name(defaultSink.volume, defaultSink.muted);
}
osd.showText(icon, defaultSink.description);
}
}
SourceModel {
......
......@@ -34,6 +34,10 @@
<method name="virtualDesktopChanged">
<arg name="currentVirtualDesktopName" type="s" direction="in"/>
</method>
<method name="showText">
<arg name="icon" type="s" direction="in"/>
<arg name="text" type="s" direction="in"/>
</method>
</interface>
</node>
......@@ -42,3 +42,9 @@ void VolumeOSD::showMicrophone(int percent)
OsdServiceInterface osdService(SERVICE, PATH, CONNECTION);
osdService.microphoneVolumeChanged(percent);
}
void VolumeOSD::showText(const QString &iconName, const QString &text)
{
OsdServiceInterface osdService(SERVICE, PATH, CONNECTION);
osdService.showText(iconName, text);
}
......@@ -32,6 +32,7 @@ public:
public slots:
void show(int percent);
void showMicrophone(int percent);
void showText(const QString &iconName, const QString &text);
};
#endif // VOLUMEOSD_H
Supports Markdown
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