Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/DeviceListItem.qml
Show All 18 Lines | |||||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.0 | 21 | import QtQuick 2.0 | ||
22 | 22 | | |||
23 | import "../code/icon.js" as Icon | 23 | import "../code/icon.js" as Icon | ||
24 | 24 | | |||
25 | ListItemBase { | 25 | ListItemBase { | ||
26 | readonly property var currentPort: Ports[ActivePortIndex] | 26 | readonly property var currentPort: Ports[ActivePortIndex] | ||
27 | readonly property var currentActivePortIndex: ActivePortIndex | ||||
28 | readonly property var currentMuted: Muted | ||||
27 | 29 | | |||
28 | draggable: false | 30 | draggable: false | ||
29 | label: { | 31 | label: { | ||
30 | if (currentPort) { | 32 | if (currentPort) { | ||
31 | var model = type === "sink" ? paSinkModel : paSourceModel; | 33 | var model = type === "sink" ? paSinkModel : paSourceModel; | ||
32 | var itemLength = currentPort.description.length; | 34 | var itemLength = currentPort.description.length; | ||
33 | for (var i = 0; i < model.rowCount(); i++) { | 35 | for (var i = 0; i < model.rowCount(); i++) { | ||
34 | if (i !== index) { | 36 | if (i !== index) { | ||
35 | var port = model.data(model.index(i, 0), model.role("Ports")) | 37 | var port = model.data(model.index(i, 0), model.role("Ports")) | ||
36 | [model.data(model.index(i, 0), model.role("ActivePortIndex"))]; | 38 | [model.data(model.index(i, 0), model.role("ActivePortIndex"))]; | ||
37 | if (port.description) { | 39 | if (port.description) { | ||
38 | var length = Math.min(itemLength, port.description.length) | 40 | var length = Math.min(itemLength, port.description.length) | ||
39 | if (currentPort.description.substring(0, length) === port.description.substring(0, length)) { | 41 | if (currentPort.description.substring(0, length) === port.description.substring(0, length)) { | ||
40 | return i18nc("label of device items", "%1 (%2)", currentPort.description, Description); | 42 | return i18nc("label of device items", "%1 (%2)", currentPort.description, Description); | ||
41 | } | 43 | } | ||
42 | } | 44 | } | ||
43 | } | 45 | } | ||
44 | } | 46 | } | ||
45 | return currentPort.description; | 47 | return currentPort.description; | ||
46 | } else { | 48 | } else { | ||
47 | return Description; | 49 | return Description; | ||
48 | } | 50 | } | ||
49 | } | 51 | } | ||
52 | | ||||
53 | onCurrentActivePortIndexChanged: { | ||||
54 | if (type === "sink" && globalMute && !Muted) { | ||||
55 | Muted = true; | ||||
56 | } | ||||
57 | } | ||||
58 | | ||||
59 | onCurrentMutedChanged: { | ||||
60 | if (type === "sink" && globalMute && !Muted) { | ||||
61 | plasmoid.configuration.globalMuteDevices = []; | ||||
62 | plasmoid.configuration.globalMute = false; | ||||
63 | globalMute = false; | ||||
64 | } | ||||
65 | } | ||||
50 | } | 66 | } |