summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rosca <[email protected]>2016-11-05 11:12:56 +0100
committerDavid Rosca <[email protected]>2016-12-15 15:03:28 +0100
commit117ff0b08deaac3b113563cd894bc8fb41fca4be (patch)
tree5e6e4be0279577f32a6e9da37387771b3023d809
parentf1798427e734339dcf3f55245485660a2dd63064 (diff)
Applet: Show device icons and active port name
Show the device name in format "Active Port: Device Name" and icon corresponding to the active port. Pulseaudio doesn't provide icon names for ports, so there is a hardcoded set of known port names and their icons. If the port name is not in this set, icon for device is used instead. Differential Revision: https://phabricator.kde.org/D3268
-rw-r--r--applet/contents/ui/DeviceListItem.qml21
1 files changed, 20 insertions, 1 deletions
diff --git a/applet/contents/ui/DeviceListItem.qml b/applet/contents/ui/DeviceListItem.qml
index 2748ca6..966a208 100644
--- a/applet/contents/ui/DeviceListItem.qml
+++ b/applet/contents/ui/DeviceListItem.qml
@@ -21,5 +21,24 @@
import QtQuick 2.0
ListItemBase {
- label: Description
+ readonly property var currentPort: Ports[ActivePortIndex]
+
+ draggable: false
+ label: currentPort ? i18nc("label of device items", "%1 (%2)", currentPort.description, Description) : Description
+ icon: {
+ if (currentPort) {
+ if (currentPort.name.indexOf("speaker") != -1) {
+ return "audio-speakers-symbolic";
+ } else if (currentPort.name.indexOf("headphones") != -1) {
+ return "audio-headphones";
+ } else if (currentPort.name.indexOf("hdmi") != -1) {
+ return "video-television";
+ } else if (currentPort.name.indexOf("mic") != -1) {
+ return "audio-input-microphone";
+ } else if (currentPort.name.indexOf("phone") != -1) {
+ return "phone";
+ }
+ }
+ return IconName || "unknown";
+ }
}