Changeset View
Changeset View
Standalone View
Standalone View
src/kcm/package/contents/ui/DeviceListItem.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright 2014-2015 Harald Sitter <sitter@kde.org> | 2 | Copyright 2014-2015 Harald Sitter <sitter@kde.org> | ||
3 | Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net> | ||||
3 | 4 | | |||
4 | This program is free software; you can redistribute it and/or | 5 | This program is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | 6 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 2 of | 7 | published by the Free Software Foundation; either version 2 of | ||
7 | the License or (at your option) version 3 or any later version | 8 | the License or (at your option) version 3 or any later version | ||
8 | accepted by the membership of KDE e.V. (or its successor approved | 9 | accepted by the membership of KDE e.V. (or its successor approved | ||
9 | by the membership of KDE e.V.), which shall act as a proxy | 10 | by the membership of KDE e.V.), which shall act as a proxy | ||
10 | defined in Section 14 of version 3 of the license. | 11 | defined in Section 14 of version 3 of the license. | ||
Show All 13 Lines | |||||
24 | 25 | | |||
25 | import org.kde.kirigami 2.5 as Kirigami | 26 | import org.kde.kirigami 2.5 as Kirigami | ||
26 | import org.kde.plasma.private.volume 0.1 | 27 | import org.kde.plasma.private.volume 0.1 | ||
27 | 28 | | |||
28 | ColumnLayout { | 29 | ColumnLayout { | ||
29 | id: delegate | 30 | id: delegate | ||
30 | width: parent.width | 31 | width: parent.width | ||
31 | 32 | | |||
33 | property bool isPlayback: type.substring(0, 4) == "sink" | ||||
34 | | ||||
35 | readonly property var currentPort: Ports[ActivePortIndex] | ||||
36 | | ||||
32 | RowLayout { | 37 | RowLayout { | ||
33 | Kirigami.Icon { | 38 | Kirigami.Icon { | ||
34 | Layout.alignment: Qt.AlignHCenter | 39 | Layout.alignment: Qt.AlignHCenter | ||
35 | width: height | 40 | width: height | ||
36 | height: inputText.height | 41 | height: inputText.height | ||
37 | source: IconName || "audio-card" | 42 | source: IconName || "audio-card" | ||
38 | } | 43 | } | ||
39 | 44 | | |||
40 | Label { | 45 | Label { | ||
41 | id: inputText | 46 | id: inputText | ||
42 | Layout.fillWidth: true | 47 | Layout.fillWidth: true | ||
43 | elide: Text.ElideRight | 48 | elide: Text.ElideRight | ||
44 | text: Description | 49 | text: !currentPort ? Description : i18ndc("kcm_pulseaudio", "label of device items", "%1 (%2)", currentPort.description, Description) | ||
45 | } | | |||
46 | | ||||
47 | Button { | | |||
48 | text: i18n("Default device") | | |||
49 | icon.name: "favorite" | | |||
50 | visible: delegate.ListView.view.count > 1 | | |||
51 | checkable: true | | |||
52 | checked: Default | | |||
53 | onClicked: Default = true; | | |||
54 | } | 50 | } | ||
55 | 51 | | |||
56 | MuteButton { | | |||
57 | muted: Muted | | |||
58 | onCheckedChanged: Muted = checked | | |||
59 | } | | |||
60 | } | | |||
61 | | ||||
62 | ColumnLayout { | | |||
63 | width: parent.width | | |||
64 | | ||||
65 | RowLayout { | | |||
66 | visible: portbox.count > 1 | | |||
67 | | ||||
68 | Label { | 52 | Label { | ||
53 | visible: portbox.count > 1 | ||||
69 | text: i18nd("kcm_pulseaudio", "Port") | 54 | text: i18nd("kcm_pulseaudio", "Port") | ||
ngraham: While we're at it, let's also make this say "Port:" | |||||
70 | } | 55 | } | ||
71 | 56 | | |||
72 | ComboBox { | 57 | ComboBox { | ||
73 | id: portbox | 58 | id: portbox | ||
59 | visible: portbox.count > 1 | ||||
74 | readonly property var ports: Ports | 60 | readonly property var ports: Ports | ||
75 | Layout.fillWidth: true | | |||
76 | onModelChanged: currentIndex = ActivePortIndex | 61 | onModelChanged: currentIndex = ActivePortIndex | ||
77 | currentIndex: ActivePortIndex | 62 | currentIndex: ActivePortIndex | ||
78 | onActivated: ActivePortIndex = index | 63 | onActivated: ActivePortIndex = index | ||
79 | 64 | | |||
80 | onPortsChanged: { | 65 | onPortsChanged: { | ||
81 | var items = []; | 66 | var items = []; | ||
82 | for (var i = 0; i < ports.length; ++i) { | 67 | for (var i = 0; i < ports.length; ++i) { | ||
83 | var port = ports[i]; | 68 | var port = ports[i]; | ||
84 | var text = port.description; | 69 | var text = port.description; | ||
85 | if (port.availability == Port.Unavailable) { | 70 | if (port.availability == Port.Unavailable) { | ||
86 | if (port.name == "analog-output-speaker" || port.name == "analog-input-microphone-internal") { | 71 | if (port.name == "analog-output-speaker" || port.name == "analog-input-microphone-internal") { | ||
87 | text += i18ndc("kcm_pulseaudio", "Port is unavailable", " (unavailable)"); | 72 | text += i18ndc("kcm_pulseaudio", "Port is unavailable", " (unavailable)"); | ||
88 | } else { | 73 | } else { | ||
89 | text += i18ndc("kcm_pulseaudio", "Port is unplugged", " (unplugged)"); | 74 | text += i18ndc("kcm_pulseaudio", "Port is unplugged", " (unplugged)"); | ||
90 | } | 75 | } | ||
91 | } | 76 | } | ||
92 | items.push(text); | 77 | items.push(text); | ||
93 | } | 78 | } | ||
94 | model = items; | 79 | model = items; | ||
95 | } | 80 | } | ||
96 | } | 81 | } | ||
82 | | ||||
83 | Button { | ||||
84 | text: i18n("Default device") | ||||
85 | icon.name: "favorite" | ||||
86 | visible: delegate.ListView.view.count > 1 | ||||
87 | checkable: true | ||||
88 | checked: Default | ||||
89 | onClicked: Default = true; | ||||
90 | } | ||||
91 | } | ||||
92 | | ||||
93 | ColumnLayout { | ||||
94 | width: parent.width | ||||
95 | | ||||
96 | RowLayout { | ||||
97 | MuteButton { | ||||
98 | muted: Muted | ||||
99 | onCheckedChanged: Muted = checked | ||||
97 | } | 100 | } | ||
98 | 101 | | |||
99 | VolumeSlider {} | 102 | VolumeSlider {} | ||
100 | } | 103 | } | ||
104 | } | ||||
GB_2: "Default Device" | |||||
101 | 105 | | |||
102 | ListItemSeperator { view: delegate.ListView.view } | 106 | ListItemSeperator { view: delegate.ListView.view } | ||
103 | } | 107 | } |
While we're at it, let's also make this say "Port:"