Commit fb563192 authored by Nate Graham's avatar Nate Graham
Browse files

Increase UI commonality between KCM and applet

Summary:
This patch beings the user interface of the applet and the KCM closer together. To
accomplish this, the following changes are made:
- Move the "Default Device" button onto the first row in the applet and make it a ToolButton to reduce its visual weight
- In both the applet and the KCM, show the port chooser UI in combobox form only when multiple ports are available; otherwise show only a text label. This is allowed by the HIG because it is a case of hardware availability (https://hig.kde.org/plattform/settings.html?highlight=inapplicable#behavior)
- Remove the port choosing functionality from the applet's hamburger menu since it's now available in the main UI when applicable

Depends on D24402

Test Plan:
Simple case: {F7509998}
More complex case: {F7509997}

Reviewers: #vdg, #plasma, drosca, broulik, sitter, sefaeyeoglu

Reviewed By: sefaeyeoglu

Subscribers: nicolasfella, ndavis, GB_2, mmustac, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24407
parent f8fb87f9
......@@ -120,6 +120,40 @@ PlasmaComponents.ListItem {
opacity: 0.6
wrapMode: Text.NoWrap
elide: Text.ElideRight
visible: !portbox.visible
}
PlasmaComponents3.ComboBox {
id: portbox
visible: portbox.count > 1
Layout.minimumWidth: units.gridUnit * 10
model: {
var items = [];
for (var i = 0; i < PulseObject.ports.length; ++i) {
var port = PulseObject.ports[i];
if (port.availability != Port.Unavailable) {
items.push(port.description);
}
}
return items
}
currentIndex: ActivePortIndex
onActivated: ActivePortIndex = index
}
Item {
visible: portbox.visible
Layout.fillWidth: true
}
PlasmaComponents3.ToolButton {
id: defaultButton
text: i18n("Default Device")
icon.name: "favorite"
checkable: true
checked: PulseObject.default
visible: (type == "sink" && sinkView.model.count > 1) || (type == "source" && sourceView.model.count > 1)
onClicked: PulseObject.default = true;
}
SmallToolButton {
......@@ -221,24 +255,6 @@ PlasmaComponents.ListItem {
text: i18nc("only used for sizing, should be widest possible string", "100%")
}
}
RowLayout {
Layout.fillWidth: true
Item {
Layout.fillWidth: true
}
PlasmaComponents3.Button {
id: defaultButton
text: i18n("Default Device")
icon.name: "favorite"
checkable: true
checked: PulseObject.default
visible: (type == "sink" && sinkView.model.count > 1) || (type == "source" && sourceView.model.count > 1)
onClicked: PulseObject.default = true;
}
}
}
}
......@@ -322,40 +338,6 @@ PlasmaComponents.ListItem {
contextMenu.addMenuItem(menuItem);
}
// Ports
if (PulseObject.ports && PulseObject.ports.length > 0) {
contextMenu.addMenuItem(newSeperator());
var isMultiplePorts = (1 < PulseObject.ports.length);
var menuItem = newMenuItem();
menuItem.text = i18nc("Heading for a list of ports of a device (for example built-in laptop speakers or a plug for headphones)", "Ports");
menuItem.section = true;
contextMenu.addMenuItem(menuItem);
for (var i = 0; i < PulseObject.ports.length; i++) {
var port = PulseObject.ports[i];
var menuItem = newMenuItem();
menuItem.text = port.description;
if (port.availability == Port.Unavailable) {
if (port.name == "analog-output-speaker" || port.name == "analog-input-microphone-internal") {
menuItem.text += i18nc("Port is unavailable", " (unavailable)");
} else {
menuItem.text += i18nc("Port is unplugged", " (unplugged)");
}
}
menuItem.enabled = isMultiplePorts;
menuItem.checkable = true;
menuItem.checked = i === PulseObject.activePortIndex;
var setActivePort = function(portIndex) {
return function() {
PulseObject.activePortIndex = portIndex;
};
};
menuItem.clicked.connect(setActivePort(i));
contextMenu.addMenuItem(menuItem);
}
}
// Choose output / input device
// By choice only shown when there are at least two options
if ((type == "sink-input" && sinkView.model.count > 1) || (type == "source-input" && sourceView.model.count > 1)) {
......
......@@ -51,39 +51,31 @@ ColumnLayout {
Label {
id: inputText
Layout.fillWidth: true
visible: !portbox.visible
elide: Text.ElideRight
text: !currentPort ? Description : i18ndc("kcm_pulseaudio", "label of device items", "%1 (%2)", currentPort.description, Description)
}
Label {
visible: portbox.count > 1
text: i18nd("kcm_pulseaudio", "Port:")
}
ComboBox {
id: portbox
visible: portbox.count > 1
readonly property var ports: Ports
onModelChanged: currentIndex = ActivePortIndex
currentIndex: ActivePortIndex
onActivated: ActivePortIndex = index
onPortsChanged: {
model: {
var items = [];
for (var i = 0; i < ports.length; ++i) {
var port = ports[i];
var text = port.description;
if (port.availability == Port.Unavailable) {
if (port.name == "analog-output-speaker" || port.name == "analog-input-microphone-internal") {
text += i18ndc("kcm_pulseaudio", "Port is unavailable", " (unavailable)");
} else {
text += i18ndc("kcm_pulseaudio", "Port is unplugged", " (unplugged)");
}
for (var i = 0; i < Ports.length; ++i) {
var port = Ports[i];
if (port.availability != Port.Unavailable) {
items.push(port.description);
}
items.push(text);
}
model = items;
return items
}
currentIndex: ActivePortIndex
onActivated: ActivePortIndex = index
}
Item {
visible: portbox.visible
Layout.fillWidth: true
}
Button {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment