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 | Layout.preferredHeight: delegateColumn.height * 0.75 | ||
36 | height: inputText.height | 41 | Layout.preferredWidth: Layout.preferredHeight | ||
37 | source: IconName || "audio-card" | 42 | source: IconName || "audio-card" | ||
38 | } | 43 | } | ||
39 | 44 | | |||
45 | ColumnLayout { | ||||
46 | id: delegateColumn | ||||
47 | Layout.fillWidth: true | ||||
48 | | ||||
49 | RowLayout { | ||||
40 | Label { | 50 | Label { | ||
41 | id: inputText | 51 | id: inputText | ||
42 | Layout.fillWidth: true | 52 | Layout.fillWidth: true | ||
ngraham: While we're at it, let's also make this say "Port:" | |||||
43 | elide: Text.ElideRight | 53 | elide: Text.ElideRight | ||
44 | text: Description | 54 | text: !currentPort ? Description : i18ndc("kcm_pulseaudio", "label of device items", "%1 (%2)", currentPort.description, Description) | ||
45 | } | 55 | } | ||
46 | 56 | | |||
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 | } | | |||
55 | | ||||
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 { | 57 | Label { | ||
69 | text: i18nd("kcm_pulseaudio", "Port") | 58 | visible: portbox.count > 1 | ||
59 | text: i18nd("kcm_pulseaudio", "Port:") | ||||
70 | } | 60 | } | ||
71 | 61 | | |||
72 | ComboBox { | 62 | ComboBox { | ||
73 | id: portbox | 63 | id: portbox | ||
64 | visible: portbox.count > 1 | ||||
74 | readonly property var ports: Ports | 65 | readonly property var ports: Ports | ||
75 | Layout.fillWidth: true | | |||
76 | onModelChanged: currentIndex = ActivePortIndex | 66 | onModelChanged: currentIndex = ActivePortIndex | ||
77 | currentIndex: ActivePortIndex | 67 | currentIndex: ActivePortIndex | ||
78 | onActivated: ActivePortIndex = index | 68 | onActivated: ActivePortIndex = index | ||
79 | 69 | | |||
80 | onPortsChanged: { | 70 | onPortsChanged: { | ||
81 | var items = []; | 71 | var items = []; | ||
82 | for (var i = 0; i < ports.length; ++i) { | 72 | for (var i = 0; i < ports.length; ++i) { | ||
83 | var port = ports[i]; | 73 | var port = ports[i]; | ||
84 | var text = port.description; | 74 | var text = port.description; | ||
85 | if (port.availability == Port.Unavailable) { | 75 | if (port.availability == Port.Unavailable) { | ||
86 | if (port.name == "analog-output-speaker" || port.name == "analog-input-microphone-internal") { | 76 | if (port.name == "analog-output-speaker" || port.name == "analog-input-microphone-internal") { | ||
87 | text += i18ndc("kcm_pulseaudio", "Port is unavailable", " (unavailable)"); | 77 | text += i18ndc("kcm_pulseaudio", "Port is unavailable", " (unavailable)"); | ||
88 | } else { | 78 | } else { | ||
89 | text += i18ndc("kcm_pulseaudio", "Port is unplugged", " (unplugged)"); | 79 | text += i18ndc("kcm_pulseaudio", "Port is unplugged", " (unplugged)"); | ||
90 | } | 80 | } | ||
91 | } | 81 | } | ||
92 | items.push(text); | 82 | items.push(text); | ||
93 | } | 83 | } | ||
94 | model = items; | 84 | model = items; | ||
95 | } | 85 | } | ||
96 | } | 86 | } | ||
87 | | ||||
88 | Button { | ||||
89 | text: i18n("Default Device") | ||||
GB_2: "Default Device" | |||||
90 | icon.name: "favorite" | ||||
91 | visible: delegate.ListView.view.count > 1 | ||||
92 | checkable: true | ||||
93 | checked: Default | ||||
94 | onClicked: Default = true; | ||||
95 | } | ||||
96 | } | ||||
97 | | ||||
98 | RowLayout { | ||||
99 | MuteButton { | ||||
100 | Layout.topMargin: -(height - icon.height) / 2 | ||||
101 | muted: Muted | ||||
102 | onCheckedChanged: Muted = checked | ||||
97 | } | 103 | } | ||
98 | 104 | | |||
99 | VolumeSlider {} | 105 | VolumeSlider {} | ||
100 | } | 106 | } | ||
107 | } | ||||
108 | } | ||||
101 | 109 | | |||
102 | ListItemSeperator { view: delegate.ListView.view } | 110 | ListItemSeperator { view: delegate.ListView.view } | ||
103 | } | 111 | } |
While we're at it, let's also make this say "Port:"