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 name = model.data(model.index(i, 0), model.role("Ports")) | 37 | var name = model.data(model.index(i, 0), model.role("Ports")) | ||
36 | [model.data(model.index(i, 0), model.role("ActivePortIndex"))].description; | 38 | [model.data(model.index(i, 0), model.role("ActivePortIndex"))].description; | ||
37 | var length = Math.min(itemLength, name.length) | 39 | var length = Math.min(itemLength, name.length) | ||
38 | if (currentPort.description.substring(0, length) === name.substring(0, length)) { | 40 | if (currentPort.description.substring(0, length) === name.substring(0, length)) { | ||
39 | return i18nc("label of device items", "%1 (%2)", currentPort.description, Description); | 41 | return i18nc("label of device items", "%1 (%2)", currentPort.description, Description); | ||
40 | } | 42 | } | ||
41 | } | 43 | } | ||
42 | } | 44 | } | ||
43 | return currentPort.description; | 45 | return currentPort.description; | ||
44 | } else { | 46 | } else { | ||
45 | return Description; | 47 | return Description; | ||
46 | } | 48 | } | ||
47 | } | 49 | } | ||
50 | | ||||
51 | onCurrentActivePortIndexChanged: { | ||||
52 | if (type === "sink" && globalMute && !Muted) { | ||||
53 | Muted = true; | ||||
54 | } | ||||
55 | } | ||||
56 | | ||||
57 | onCurrentMutedChanged: { | ||||
58 | if (type === "sink" && globalMute && !Muted) { | ||||
59 | plasmoid.configuration.globalMuteDevices = []; | ||||
60 | plasmoid.configuration.globalMute = false; | ||||
61 | globalMute = false; | ||||
62 | } | ||||
63 | } | ||||
48 | } | 64 | } |