Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/DeviceListItem.qml
Show All 14 Lines | 1 | /* | |||
---|---|---|---|---|---|
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.0 | 21 | import QtQuick 2.0 | ||
22 | 22 | | |||
23 | import org.kde.plasma.private.volume 0.1 | ||||
24 | | ||||
23 | import "../code/icon.js" as Icon | 25 | import "../code/icon.js" as Icon | ||
24 | 26 | | |||
25 | ListItemBase { | 27 | ListItemBase { | ||
26 | readonly property var currentPort: Ports[ActivePortIndex] | 28 | readonly property var currentPort: Ports[ActivePortIndex] | ||
27 | readonly property var currentActivePortIndex: ActivePortIndex | 29 | readonly property var currentActivePortIndex: ActivePortIndex | ||
28 | readonly property var currentMuted: Muted | 30 | readonly property var currentMuted: Muted | ||
31 | readonly property var activePortIndex: ActivePortIndex | ||||
29 | 32 | | |||
30 | draggable: false | 33 | draggable: false | ||
31 | label: { | 34 | label: { | ||
32 | if (currentPort) { | 35 | if (currentPort) { | ||
33 | var model = type === "sink" ? paSinkModel : paSourceModel; | 36 | var model = type === "sink" ? paSinkModel : paSourceModel; | ||
34 | var itemLength = currentPort.description.length; | 37 | var itemLength = currentPort.description.length; | ||
35 | for (var i = 0; i < model.rowCount(); i++) { | 38 | for (var i = 0; i < model.rowCount(); i++) { | ||
36 | if (i !== index) { | 39 | if (i !== index) { | ||
Show All 10 Lines | |||||
47 | return currentPort.description; | 50 | return currentPort.description; | ||
48 | } else { | 51 | } else { | ||
49 | return Description; | 52 | return Description; | ||
50 | } | 53 | } | ||
51 | } | 54 | } | ||
52 | 55 | | |||
53 | onCurrentActivePortIndexChanged: { | 56 | onCurrentActivePortIndexChanged: { | ||
54 | if (type === "sink" && globalMute && !Muted) { | 57 | if (type === "sink" && globalMute && !Muted) { | ||
55 | Muted = true; | 58 | Muted = true; | ||
gvgeo: if (description) | |||||
56 | } | 59 | } | ||
57 | } | 60 | } | ||
58 | 61 | | |||
59 | onCurrentMutedChanged: { | 62 | onCurrentMutedChanged: { | ||
60 | if (type === "sink" && globalMute && !Muted) { | 63 | if (type === "sink" && globalMute && !Muted) { | ||
61 | plasmoid.configuration.globalMuteDevices = []; | 64 | plasmoid.configuration.globalMuteDevices = []; | ||
62 | plasmoid.configuration.globalMute = false; | 65 | plasmoid.configuration.globalMute = false; | ||
63 | globalMute = false; | 66 | globalMute = false; | ||
64 | } | 67 | } | ||
65 | } | 68 | } | ||
69 | | ||||
70 | // Prevent an unavailable port selection. UI allows selection of an unavailable port, until it gets refresh, | ||||
71 | // because there is no call from pulseaudio for availability change. | ||||
72 | onActivePortIndexChanged: { | ||||
73 | if (currentPort.availability === Port.Unavailable) { | ||||
74 | for (var i = 0; i < Ports.length; i++) { | ||||
75 | if (Ports[i].availability === Port.Available) { | ||||
76 | ActivePortIndex = i; | ||||
77 | return | ||||
78 | } | ||||
79 | } | ||||
80 | } | ||||
81 | } | ||||
66 | } | 82 | } |
if (description)