Commit 1b737cfe authored by George Vogiatzis's avatar George Vogiatzis Committed by Nate Graham

[Applet] Display device name when there is than one device

Summary:
Display both device name and port if there is more than one device.
Applies separately for playback and recording devices.

BUG: 417079

Reviewers: #plasma, #vdg, drosca, ngraham

Reviewed By: #vdg, ngraham

Subscribers: cgiboudeaux, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27138
parent 5cfea2e6
......@@ -29,28 +29,17 @@ ListItemBase {
readonly property var currentActivePortIndex: ActivePortIndex
readonly property var currentMuted: Muted
readonly property var activePortIndex: ActivePortIndex
property bool onlyone: false
draggable: false
label: {
if (currentPort && currentPort.description) {
var model = type === "sink" ? paSinkModel : paSourceModel;
var itemLength = currentPort.description.length;
for (var i = 0; i < model.rowCount(); i++) {
if (i !== index) {
var port = model.data(model.index(i, 0), model.role("Ports"))
[model.data(model.index(i, 0), model.role("ActivePortIndex"))];
if (port && port.description) {
var length = Math.min(itemLength, port.description.length)
if (currentPort.description.substring(0, length) === port.description.substring(0, length)) {
return i18nc("label of device items", "%1 (%2)", currentPort.description, Description);
}
}
}
if (currentPort) {
if (onlyone) {
return currentPort.description;
}
return currentPort.description;
} else {
return Description;
return i18nc("label of device items", "%1 (%2)", currentPort.description, Description);
}
return Description;
}
onCurrentActivePortIndexChanged: {
......
......@@ -434,7 +434,6 @@ Item {
id: streamsView
spacing: 0
visible: tabBar.currentTab == streamsTab
readonly property bool simpleMode: (sinkInputView.count >= 1 && sourceOutputView.count == 0) || (sinkInputView.count == 0 && sourceOutputView.count >= 1)
property int maximumWidth: scrollView.viewport.width
width: maximumWidth
Layout.maximumWidth: maximumWidth
......@@ -490,7 +489,6 @@ Item {
ColumnLayout {
id: devicesView
visible: tabBar.currentTab == devicesTab
readonly property bool simpleMode: sinkView.count == 1 && sourceView.count == 1
property int maximumWidth: scrollView.viewport.width
width: maximumWidth
Layout.maximumWidth: maximumWidth
......@@ -522,6 +520,7 @@ Item {
boundsBehavior: Flickable.StopAtBounds;
delegate: DeviceListItem {
type: "sink"
onlyone: sinkView.count === 1
}
}
......@@ -551,6 +550,7 @@ Item {
boundsBehavior: Flickable.StopAtBounds;
delegate: DeviceListItem {
type: "source"
onlyone: sourceView.count === 1
}
}
}
......
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