Changeset View
Changeset View
Standalone View
Standalone View
src/kcm/package/contents/ui/DeviceListItem.qml
Show All 23 Lines | |||||
24 | import QtQuick.Layouts 1.0 | 24 | import QtQuick.Layouts 1.0 | ||
25 | 25 | | |||
26 | import org.kde.kirigami 2.5 as Kirigami | 26 | import org.kde.kirigami 2.5 as Kirigami | ||
27 | import org.kde.plasma.private.volume 0.1 | 27 | import org.kde.plasma.private.volume 0.1 | ||
28 | import "../code/icon.js" as Icon | 28 | import "../code/icon.js" as Icon | ||
29 | 29 | | |||
30 | ColumnLayout { | 30 | ColumnLayout { | ||
31 | id: delegate | 31 | id: delegate | ||
32 | spacing: units.smallSpacing * 2 | ||||
davidedmundson: Kirigami.Units.smallSpacing please
(for all units in KCM code)
again, for complex reasons… | |||||
32 | width: parent.width | 33 | width: parent.width | ||
33 | 34 | | |||
34 | property bool isPlayback: type.substring(0, 4) == "sink" | 35 | property bool isPlayback: type.substring(0, 4) == "sink" | ||
35 | 36 | | |||
36 | readonly property var currentPort: Ports[ActivePortIndex] | 37 | readonly property var currentPort: Ports[ActivePortIndex] | ||
37 | 38 | | |||
38 | RowLayout { | 39 | RowLayout { | ||
39 | Kirigami.Icon { | 40 | spacing: units.smallSpacing | ||
40 | Layout.alignment: Qt.AlignHCenter | 41 | Layout.minimumHeight: portbox.implicitHeight | ||
41 | Layout.preferredHeight: delegateColumn.height * 0.75 | 42 | | ||
42 | Layout.preferredWidth: Layout.preferredHeight | 43 | RadioButton { | ||
43 | source: Icon.formFactorIcon(FormFactor) || IconName || "audio-card" | 44 | id: defaultButton | ||
45 | // Maximum width of the button need to match the text. Empty area must not change the default device. | ||||
46 | Layout.maximumWidth: delegate.width - Layout.leftMargin - Layout.rightMargin | ||||
47 | - (portbox.visible ? units.gridUnit + portLabel.implicitWidth + units.smallSpacing + portbox.implicitWidth : 0) | ||||
48 | // Margins and spacing are set to center RadioButton with muteButton, and text with VolumeSlider. | ||||
49 | Layout.leftMargin: LayoutMirroring.enabled ? 0 : Math.round((muteButton.width - defaultButton.indicator.width) / 2) | ||||
50 | Layout.rightMargin: LayoutMirroring.enabled ? Math.round((muteButton.width - defaultButton.indicator.width) / 2) : 0 | ||||
51 | spacing: units.smallSpacing + Math.round((muteButton.width - defaultButton.indicator.width) / 2) | ||||
52 | checked: Default | ||||
53 | visible: delegate.ListView.view.count > 1 | ||||
54 | onClicked: Default = true | ||||
55 | text: !currentPort ? Description : i18ndc("kcm_pulseaudio", "label of device items", "%1 (%2)", currentPort.description, Description) | ||||
44 | } | 56 | } | ||
45 | 57 | | |||
46 | ColumnLayout { | 58 | Label { | ||
47 | id: delegateColumn | 59 | id: soloLabel | ||
60 | Layout.maximumWidth: delegate.width - (portbox.visible ? units.gridUnit + portLabel.implicitWidth + units.smallSpacing + portbox.implicitWidth : 0) | ||||
61 | text: defaultButton.text | ||||
62 | visible: !defaultButton.visible | ||||
63 | elide: Text.ElideRight | ||||
64 | } | ||||
65 | | ||||
66 | Item { | ||||
48 | Layout.fillWidth: true | 67 | Layout.fillWidth: true | ||
68 | visible: portbox.visible | ||||
69 | } | ||||
49 | 70 | | |||
50 | RowLayout { | | |||
51 | Label { | 71 | Label { | ||
52 | id: inputText | 72 | id: portLabel | ||
53 | Layout.fillWidth: true | 73 | visible: portbox.visible | ||
54 | visible: !portbox.visible | 74 | text: i18nd("kcm_pulseaudio", "Port:") | ||
55 | elide: Text.ElideRight | | |||
56 | text: !currentPort ? Description : i18ndc("kcm_pulseaudio", "label of device items", "%1 (%2)", currentPort.description, Description) | | |||
57 | } | 75 | } | ||
58 | 76 | | |||
59 | ComboBox { | 77 | ComboBox { | ||
60 | id: portbox | 78 | id: portbox | ||
61 | visible: portbox.count > 1 | 79 | visible: portbox.count > 1 | ||
62 | model: { | 80 | readonly property var ports: Ports | ||
81 | onModelChanged: currentIndex = ActivePortIndex | ||||
82 | currentIndex: ActivePortIndex | ||||
83 | onActivated: ActivePortIndex = index | ||||
84 | | ||||
85 | onPortsChanged: { | ||||
63 | var items = []; | 86 | var items = []; | ||
64 | for (var i = 0; i < Ports.length; ++i) { | 87 | for (var i = 0; i < ports.length; ++i) { | ||
65 | var port = Ports[i]; | 88 | var port = ports[i]; | ||
66 | if (port.availability != Port.Unavailable) { | 89 | var text = port.description; | ||
67 | items.push(port.description); | 90 | if (port.availability == Port.Unavailable) { | ||
91 | if (port.name == "analog-output-speaker" || port.name == "analog-input-microphone-internal") { | ||||
92 | text += i18ndc("kcm_pulseaudio", "Port is unavailable", " (unavailable)"); | ||||
93 | } else { | ||||
94 | text += i18ndc("kcm_pulseaudio", "Port is unplugged", " (unplugged)"); | ||||
68 | } | 95 | } | ||
69 | } | 96 | } | ||
70 | return items | 97 | items.push(text); | ||
71 | } | 98 | } | ||
72 | currentIndex: ActivePortIndex | 99 | model = items; | ||
73 | onActivated: ActivePortIndex = index | | |||
74 | } | 100 | } | ||
75 | | ||||
76 | Item { | | |||
77 | visible: portbox.visible | | |||
78 | Layout.fillWidth: true | | |||
79 | } | | |||
80 | | ||||
81 | Button { | | |||
82 | text: i18n("Default Device") | | |||
83 | icon.name: Default ? "starred-symbolic" : "non-starred-symbolic" | | |||
84 | visible: delegate.ListView.view.count > 1 | | |||
85 | checkable: true | | |||
86 | checked: Default | | |||
87 | onClicked: Default = true; | | |||
88 | } | 101 | } | ||
89 | } | 102 | } | ||
90 | 103 | | |||
91 | RowLayout { | 104 | RowLayout { | ||
105 | spacing: units.smallSpacing | ||||
106 | Layout.preferredWidth: parent.width | ||||
Do you need this? It should be the same as Layout.fillWidth which will be on by default for a layout in a layout davidedmundson: Do you need this?
It should be the same as Layout.fillWidth which will be on by default for a… | |||||
107 | | ||||
92 | MuteButton { | 108 | MuteButton { | ||
109 | id: muteButton | ||||
93 | Layout.topMargin: -(height - icon.height) / 2 | 110 | Layout.topMargin: -(height - icon.height) / 2 | ||
94 | muted: Muted | 111 | muted: Muted | ||
95 | onCheckedChanged: Muted = checked | 112 | onCheckedChanged: Muted = checked | ||
113 | toolTipText: !currentPort ? Description : currentPort.description | ||||
96 | } | 114 | } | ||
97 | 115 | | |||
98 | VolumeSlider {} | 116 | VolumeSlider {} | ||
99 | } | 117 | } | ||
100 | } | 118 | } | ||
101 | } | | |||
102 | | ||||
103 | ListItemSeperator { view: delegate.ListView.view } | | |||
104 | } | |
Kirigami.Units.smallSpacing please
(for all units in KCM code)
again, for complex reasons, sorry.