diff --git a/applet/contents/code/icon.js b/applet/contents/code/icon.js
--- a/applet/contents/code/icon.js
+++ b/applet/contents/code/icon.js
@@ -35,3 +35,37 @@
}
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 "";
+}
diff --git a/applet/contents/config/main.xml b/applet/contents/config/main.xml
--- a/applet/contents/config/main.xml
+++ b/applet/contents/config/main.xml
@@ -15,6 +15,10 @@
true
+
+
+ true
+
diff --git a/applet/contents/ui/ConfigGeneral.qml b/applet/contents/ui/ConfigGeneral.qml
--- a/applet/contents/ui/ConfigGeneral.qml
+++ b/applet/contents/ui/ConfigGeneral.qml
@@ -28,6 +28,7 @@
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 @@
text: i18n("Volume feedback")
enabled: feedback.valid
}
+
+ CheckBox {
+ id: outputChangeOsd
+ text: i18n("Visual feedback when default output device changes")
+ }
}
}
}
diff --git a/applet/contents/ui/DeviceListItem.qml b/applet/contents/ui/DeviceListItem.qml
--- a/applet/contents/ui/DeviceListItem.qml
+++ b/applet/contents/ui/DeviceListItem.qml
@@ -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 @@
}
}
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
}
diff --git a/applet/contents/ui/main.qml b/applet/contents/ui/main.qml
--- a/applet/contents/ui/main.qml
+++ b/applet/contents/ui/main.qml
@@ -149,6 +149,26 @@
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 {
diff --git a/src/qml/dbus/osdService.xml b/src/qml/dbus/osdService.xml
--- a/src/qml/dbus/osdService.xml
+++ b/src/qml/dbus/osdService.xml
@@ -34,6 +34,10 @@
+
+
+
+
diff --git a/src/qml/volumeosd.h b/src/qml/volumeosd.h
--- a/src/qml/volumeosd.h
+++ b/src/qml/volumeosd.h
@@ -32,6 +32,7 @@
public slots:
void show(int percent);
void showMicrophone(int percent);
+ void showText(const QString &iconName, const QString &text);
};
#endif // VOLUMEOSD_H
diff --git a/src/qml/volumeosd.cpp b/src/qml/volumeosd.cpp
--- a/src/qml/volumeosd.cpp
+++ b/src/qml/volumeosd.cpp
@@ -42,3 +42,9 @@
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);
+}