Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/ListItemBase.qml
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 36 | PlasmaComponents.ListItem { | |||
---|---|---|---|---|---|
51 | Item { | 51 | Item { | ||
52 | width: parent.width | 52 | width: parent.width | ||
53 | height: column.height | 53 | height: column.height | ||
54 | 54 | | |||
55 | RowLayout { | 55 | RowLayout { | ||
56 | id: rowLayout | 56 | id: rowLayout | ||
57 | anchors.left: parent.left | 57 | anchors.left: parent.left | ||
58 | anchors.right: parent.right | 58 | anchors.right: parent.right | ||
59 | anchors.rightMargin: LayoutMirroring.enabled ? 0 : units.smallSpacing | | |||
60 | anchors.leftMargin: LayoutMirroring.enabled ? units.smallSpacing : 0 | | |||
61 | 59 | | |||
62 | PlasmaCore.IconItem { | 60 | PlasmaCore.IconItem { | ||
63 | id: clientIcon | 61 | id: clientIcon | ||
64 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter | 62 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter | ||
65 | Layout.preferredHeight: column.height * 0.75 | 63 | Layout.preferredHeight: column.height * 0.75 | ||
66 | Layout.preferredWidth: Layout.preferredHeight | 64 | Layout.preferredWidth: Layout.preferredHeight | ||
67 | source: "unknown" | 65 | source: "unknown" | ||
68 | visible: type === "sink-input" || type === "source-input" | 66 | visible: type === "sink-input" || type === "source-input" | ||
Show All 36 Lines | |||||
105 | } | 103 | } | ||
106 | } | 104 | } | ||
107 | 105 | | |||
108 | ColumnLayout { | 106 | ColumnLayout { | ||
109 | id: column | 107 | id: column | ||
110 | spacing: 0 | 108 | spacing: 0 | ||
111 | 109 | | |||
112 | RowLayout { | 110 | RowLayout { | ||
113 | Layout.minimumHeight: contextMenuButton.height | 111 | Layout.minimumHeight: contextMenuButton.height | ||
davidedmundson: That's asking for a binding loop.
An implicit size should never be based on a current size. | |||||
114 | 112 | | |||
115 | PlasmaComponents3.RadioButton { | 113 | PlasmaComponents3.RadioButton { | ||
Give the radio button a text: property and remove the heading item; that way the text will be clickable ngraham: Give the radio button a `text:` property and remove the heading item; that way the text will be… | |||||
116 | id: defaultButton | 114 | id: defaultButton | ||
117 | Layout.leftMargin: LayoutMirroring.enabled ? 0 : Math.round((muteButton.width - defaultButton.indicator.width) / 2) | 115 | Layout.leftMargin: LayoutMirroring.enabled ? 0 : Math.round((muteButton.width - defaultButton.indicator.width) / 2) | ||
Margins should but don't get mirrored when using a RTL layout. I haven't tested anything, but I think you need to add a rightMargin when layout mirroring is enabled. filipf: Margins should but don't get mirrored when using a RTL layout. I haven't tested anything, but I… | |||||
Don't multiply by 0.75; this could result in a fractional value and the spacing doesn't doesn't need to be literally pixel-identical with the mockup ngraham: Don't multiply by 0.75; this could result in a fractional value and the spacing doesn't doesn't… | |||||
118 | Layout.rightMargin: LayoutMirroring.enabled ? Math.round((muteButton.width - defaultButton.indicator.width) / 2) : 0 | 116 | Layout.rightMargin: LayoutMirroring.enabled ? Math.round((muteButton.width - defaultButton.indicator.width) / 2) : 0 | ||
Don't override this here. If it looks bad, let's fix it in the RadioButton control itself ngraham: Don't override this here. If it looks bad, let's fix it in the RadioButton control itself | |||||
119 | spacing: units.smallSpacing + Math.round((muteButton.width - defaultButton.indicator.width) / 2) | 117 | spacing: units.smallSpacing + Math.round((muteButton.width - defaultButton.indicator.width) / 2) | ||
120 | checked: PulseObject.default ? PulseObject.default : false | 118 | checked: PulseObject.default ? PulseObject.default : false | ||
121 | visible: (type == "sink" && sinkView.model.count > 1) || (type == "source" && sourceView.model.count > 1) | 119 | visible: (type == "sink" && sinkView.model.count > 1) || (type == "source" && sourceView.model.count > 1) | ||
122 | onClicked: PulseObject.default = true; | 120 | onClicked: PulseObject.default = true; | ||
123 | } | 121 | } | ||
124 | 122 | | |||
125 | Label { | 123 | Label { | ||
126 | id: soloLabel | 124 | id: soloLabel | ||
127 | text: defaultButton.text | 125 | text: defaultButton.text | ||
128 | visible: !defaultButton.visible | 126 | visible: !defaultButton.visible | ||
129 | elide: Text.ElideRight | 127 | elide: Text.ElideRight | ||
ngraham: This is the default wrap value; no need to explicitly set it | |||||
130 | } | 128 | } | ||
131 | 129 | | |||
132 | Item { | 130 | Item { | ||
133 | Layout.fillWidth: true | 131 | Layout.fillWidth: true | ||
134 | } | 132 | } | ||
135 | 133 | | |||
136 | SmallToolButton { | 134 | SmallToolButton { | ||
137 | id: contextMenuButton | 135 | id: contextMenuButton | ||
138 | icon: "application-menu" | 136 | icon: "application-menu" | ||
139 | checkable: true | 137 | checkable: true | ||
140 | onClicked: contextMenu.show() | 138 | onClicked: contextMenu.show() | ||
141 | tooltip: i18n("Show additional options for %1", defaultButton.text) | 139 | tooltip: i18n("Show additional options for %1", defaultButton.text) | ||
140 | visible: { | ||||
141 | if (((type == "sink-input" || type == "sink") && sinkView.model.count > 1) | ||||
142 | || ((type == "source-input" || type == "source") && sourceView.model.count > 1)) { | ||||
143 | return true; | ||||
144 | } else if (PulseObject.ports) { | ||||
145 | var foundFirstAvailablePort = false; | ||||
146 | for (var i = 0; i < PulseObject.ports.length; i++) { | ||||
147 | if (PulseObject.ports[i].availability != Port.Unavailable) { | ||||
148 | if (foundFirstAvailablePort) { | ||||
149 | return true; | ||||
150 | } else { | ||||
151 | foundFirstAvailablePort = true; | ||||
152 | } | ||||
153 | } | ||||
154 | } | ||||
155 | } | ||||
156 | return false; | ||||
157 | } | ||||
142 | } | 158 | } | ||
143 | } | 159 | } | ||
144 | 160 | | |||
145 | RowLayout { | 161 | RowLayout { | ||
146 | SmallToolButton { | 162 | SmallToolButton { | ||
147 | id: muteButton | 163 | id: muteButton | ||
148 | readonly property bool isPlayback: type.substring(0, 4) == "sink" | 164 | readonly property bool isPlayback: type.substring(0, 4) == "sink" | ||
149 | icon: Icon.name(Volume, Muted, isPlayback ? "audio-volume" : "microphone-sensitivity") | 165 | icon: Icon.name(Volume, Muted, isPlayback ? "audio-volume" : "microphone-sensitivity") | ||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 280 | PlasmaComponents.ContextMenu { | |||
279 | function newMenuItem() { | 295 | function newMenuItem() { | ||
280 | return Qt.createQmlObject("import org.kde.plasma.components 2.0 as PlasmaComponents; PlasmaComponents.MenuItem {}", contextMenu); | 296 | return Qt.createQmlObject("import org.kde.plasma.components 2.0 as PlasmaComponents; PlasmaComponents.MenuItem {}", contextMenu); | ||
281 | } | 297 | } | ||
282 | 298 | | |||
283 | function loadDynamicActions() { | 299 | function loadDynamicActions() { | ||
284 | contextMenu.clearMenuItems(); | 300 | contextMenu.clearMenuItems(); | ||
285 | 301 | | |||
286 | // Switch all streams of the relevant kind to this device | 302 | // Switch all streams of the relevant kind to this device | ||
287 | if (type == "source") { | 303 | if (type == "source" && sourceView.model.count > 1) { | ||
288 | menuItem = newMenuItem(); | 304 | menuItem = newMenuItem(); | ||
289 | menuItem.text = i18n("Record all audio via this device"); | 305 | menuItem.text = i18n("Record all audio via this device"); | ||
290 | menuItem.icon = "mic-on" // or "mic-ready" // or "audio-input-microphone-symbolic" | 306 | menuItem.icon = "mic-on" // or "mic-ready" // or "audio-input-microphone-symbolic" | ||
291 | menuItem.clicked.connect(function() { | 307 | menuItem.clicked.connect(function() { | ||
292 | PulseObject.switchStreams(); | 308 | PulseObject.switchStreams(); | ||
293 | }); | 309 | }); | ||
294 | contextMenu.addMenuItem(menuItem); | 310 | contextMenu.addMenuItem(menuItem); | ||
295 | } else if (type == "sink") { | 311 | } else if (type == "sink" && sinkView.model.count > 1) { | ||
296 | menuItem = newMenuItem(); | 312 | menuItem = newMenuItem(); | ||
297 | menuItem.text = i18n("Play all audio via this device"); | 313 | menuItem.text = i18n("Play all audio via this device"); | ||
298 | menuItem.icon = "audio-on" // or "audio-ready" // or "audio-speakers-symbolic" | 314 | menuItem.icon = "audio-on" // or "audio-ready" // or "audio-speakers-symbolic" | ||
299 | menuItem.clicked.connect(function() { | 315 | menuItem.clicked.connect(function() { | ||
300 | PulseObject.switchStreams(); | 316 | PulseObject.switchStreams(); | ||
301 | }); | 317 | }); | ||
302 | contextMenu.addMenuItem(menuItem); | 318 | contextMenu.addMenuItem(menuItem); | ||
303 | } | 319 | } | ||
304 | 320 | | |||
305 | // Ports | 321 | // Ports | ||
306 | // Intentionally only shown when there are at least two available ports. | 322 | // Intentionally only shown when there are at least two available ports. | ||
ngraham: By choice -> Intentionally | |||||
307 | if (PulseObject.ports && PulseObject.ports.length > 1) { | 323 | if (PulseObject.ports && PulseObject.ports.length > 1) { | ||
308 | contextMenu.addMenuItem(newSeperator()); | 324 | contextMenu.addMenuItem(newSeperator()); | ||
309 | 325 | | |||
310 | var menuItem = newMenuItem(); | 326 | var menuItem = newMenuItem(); | ||
311 | menuItem.text = i18nc("Heading for a list of ports of a device (for example built-in laptop speakers or a plug for headphones)", "Ports"); | 327 | menuItem.text = i18nc("Heading for a list of ports of a device (for example built-in laptop speakers or a plug for headphones)", "Ports"); | ||
312 | menuItem.section = true; | 328 | menuItem.section = true; | ||
313 | contextMenu.addMenuItem(menuItem); | 329 | contextMenu.addMenuItem(menuItem); | ||
314 | menuItem.visible = false; | 330 | menuItem.visible = false; | ||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |
That's asking for a binding loop.
An implicit size should never be based on a current size.
This could be:
Layout.minimumHeight: contextMenuButton.implicitHeight
Though I'm surprised you need this line at all.