[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [plasma-pa] applet/contents/ui: Show "muted" icon in panel and disable shortcuts for Dummy Output
From:       Kai Uwe Broulik <null () kde ! org>
Date:       2018-09-26 15:36:02
Message-ID: E1g5Br8-0007EG-QP () code ! kde ! org
[Download RAW message or body]

Git commit 2ca95da77563c0d62a8a540673d81f772239444d by Kai Uwe Broulik.
Committed on 26/09/2018 at 15:35.
Pushed by broulik into branch 'master'.

Show "muted" icon in panel and disable shortcuts for Dummy Output

The "Dummy Output" doesn't play any sound, so indicate that in the panel.
Also disable the volume shortcuts in this case.

Differential Revision: https://phabricator.kde.org/D15769

M  +11   -6    applet/contents/ui/main.qml

https://commits.kde.org/plasma-pa/2ca95da77563c0d62a8a540673d81f772239444d

diff --git a/applet/contents/ui/main.qml b/applet/contents/ui/main.qml
index 00dd620..8ae841a 100644
--- a/applet/contents/ui/main.qml
+++ b/applet/contents/ui/main.qml
@@ -44,7 +44,8 @@ Item {
     Layout.preferredHeight: units.gridUnit * 20
     Layout.preferredWidth: units.gridUnit * 20
 
-    Plasmoid.icon: paSinkModel.preferredSink ? \
Icon.name(paSinkModel.preferredSink.volume, paSinkModel.preferredSink.muted) : \
Icon.name(0, true) +    Plasmoid.icon: paSinkModel.preferredSink && \
!isDummyOutput(paSinkModel.preferredSink) ? \
Icon.name(paSinkModel.preferredSink.volume, paSinkModel.preferredSink.muted) +        \
: Icon.name(0, true)  Plasmoid.switchWidth: units.gridUnit * 12
     Plasmoid.switchHeight: units.gridUnit * 12
     Plasmoid.toolTipMainText: {
@@ -61,6 +62,11 @@ Item {
     }
     Plasmoid.toolTipSubText: paSinkModel.preferredSink ? \
paSinkModel.preferredSink.description : ""  
+    function isDummyOutput(output) {
+        // DEFAULT_SINK_NAME in module-always-sink.c
+        return output && output.name === "auto_null"
+    }
+
     function boundVolume(volume) {
         return Math.max(PulseAudio.MinimalVolume, Math.min(volume, maxVolumeValue));
     }
@@ -73,7 +79,7 @@ Item {
     }
 
     function increaseVolume() {
-        if (!paSinkModel.preferredSink) {
+        if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) \
{  return;
         }
         var volume = boundVolume(paSinkModel.preferredSink.volume + volumeStep);
@@ -85,7 +91,7 @@ Item {
     }
 
     function decreaseVolume() {
-        if (!paSinkModel.preferredSink) {
+        if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) \
{  return;
         }
         var volume = boundVolume(paSinkModel.preferredSink.volume - volumeStep);
@@ -97,7 +103,7 @@ Item {
     }
 
     function muteVolume() {
-        if (!paSinkModel.preferredSink) {
+        if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) \
{  return;
         }
         var toMute = !paSinkModel.preferredSink.muted;
@@ -166,8 +172,7 @@ Item {
             var icon = Icon.formFactorIcon(defaultSink.formFactor);
             if (!icon) {
                 // Show "muted" icon for Dummy output
-                // DEFAULT_SINK_NAME in module-always-sink.c
-                if (defaultSink.name === "auto_null") {
+                if (isDummyOutput(defaultSink)) {
                     icon = "audio-volume-muted";
                 }
             }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic