diff --git a/src/kcm/package/contents/ui/DeviceListItem.qml b/src/kcm/package/contents/ui/DeviceListItem.qml --- a/src/kcm/package/contents/ui/DeviceListItem.qml +++ b/src/kcm/package/contents/ui/DeviceListItem.qml @@ -29,76 +29,90 @@ ColumnLayout { id: delegate + spacing: units.smallSpacing * 2 width: parent.width property bool isPlayback: type.substring(0, 4) == "sink" readonly property var currentPort: Ports[ActivePortIndex] RowLayout { - Kirigami.Icon { - Layout.alignment: Qt.AlignHCenter - Layout.preferredHeight: delegateColumn.height * 0.75 - Layout.preferredWidth: Layout.preferredHeight - source: Icon.formFactorIcon(FormFactor) || IconName || "audio-card" + spacing: units.smallSpacing + Layout.minimumHeight: portbox.implicitHeight + + RadioButton { + id: defaultButton + // Maximum width of the button need to match the text. Empty area must not change the default device. + Layout.maximumWidth: delegate.width - Layout.leftMargin - Layout.rightMargin + - (portbox.visible ? units.gridUnit + portLabel.implicitWidth + units.smallSpacing + portbox.implicitWidth : 0) + // Margins and spacing are set to center RadioButton with muteButton, and text with VolumeSlider. + Layout.leftMargin: LayoutMirroring.enabled ? 0 : Math.round((muteButton.width - defaultButton.indicator.width) / 2) + Layout.rightMargin: LayoutMirroring.enabled ? Math.round((muteButton.width - defaultButton.indicator.width) / 2) : 0 + spacing: units.smallSpacing + Math.round((muteButton.width - defaultButton.indicator.width) / 2) + checked: Default + visible: delegate.ListView.view.count > 1 + onClicked: Default = true + text: !currentPort ? Description : i18ndc("kcm_pulseaudio", "label of device items", "%1 (%2)", currentPort.description, Description) } - ColumnLayout { - id: delegateColumn + Label { + id: soloLabel + Layout.maximumWidth: delegate.width - (portbox.visible ? units.gridUnit + portLabel.implicitWidth + units.smallSpacing + portbox.implicitWidth : 0) + text: defaultButton.text + visible: !defaultButton.visible + elide: Text.ElideRight + } + + Item { Layout.fillWidth: true + visible: portbox.visible + } - RowLayout { - 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 { + id: portLabel + visible: portbox.visible + text: i18nd("kcm_pulseaudio", "Port:") + } - ComboBox { - id: portbox - visible: portbox.count > 1 - model: { - var items = []; - for (var i = 0; i < Ports.length; ++i) { - var port = Ports[i]; - if (port.availability != Port.Unavailable) { - items.push(port.description); - } + ComboBox { + id: portbox + visible: portbox.count > 1 + readonly property var ports: Ports + onModelChanged: currentIndex = ActivePortIndex + currentIndex: ActivePortIndex + onActivated: ActivePortIndex = index + + onPortsChanged: { + 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)"); } - return items } - currentIndex: ActivePortIndex - onActivated: ActivePortIndex = index - } - - Item { - visible: portbox.visible - Layout.fillWidth: true - } - - Button { - text: i18n("Default Device") - icon.name: Default ? "starred-symbolic" : "non-starred-symbolic" - visible: delegate.ListView.view.count > 1 - checkable: true - checked: Default - onClicked: Default = true; + items.push(text); } - } - - RowLayout { - MuteButton { - Layout.topMargin: -(height - icon.height) / 2 - muted: Muted - onCheckedChanged: Muted = checked - } - - VolumeSlider {} + model = items; } } } - ListItemSeperator { view: delegate.ListView.view } + RowLayout { + spacing: units.smallSpacing + Layout.preferredWidth: parent.width + + MuteButton { + id: muteButton + Layout.topMargin: -(height - icon.height) / 2 + muted: Muted + onCheckedChanged: Muted = checked + toolTipText: !currentPort ? Description : currentPort.description + } + + VolumeSlider {} + } } diff --git a/src/kcm/package/contents/ui/Devices.qml b/src/kcm/package/contents/ui/Devices.qml --- a/src/kcm/package/contents/ui/Devices.qml +++ b/src/kcm/package/contents/ui/Devices.qml @@ -53,7 +53,7 @@ Layout.preferredHeight: contentHeight Layout.margins: units.gridUnit / 2 interactive: false - spacing: units.smallSpacing * 2 + spacing: units.gridUnit model: sinkModel delegate: DeviceListItem { isPlayback: true @@ -73,6 +73,7 @@ Layout.preferredHeight: contentHeight Layout.margins: units.gridUnit / 2 interactive: false + spacing: units.gridUnit model: sourceModel delegate: DeviceListItem { isPlayback: false diff --git a/src/kcm/package/contents/ui/MuteButton.qml b/src/kcm/package/contents/ui/MuteButton.qml --- a/src/kcm/package/contents/ui/MuteButton.qml +++ b/src/kcm/package/contents/ui/MuteButton.qml @@ -25,13 +25,14 @@ QQC2.ToolButton { property bool muted: true + property var toolTipText icon.name: Icon.name(Volume, Muted, isPlayback ? "audio-volume" : "microphone-sensitivity") checkable: true checked: muted onMutedChanged: checked = muted QQC2.ToolTip { - text: i18ndc("kcm_pulseaudio", "Mute audio stream", "Mute %1", inputText.text) // a little hacky + text: i18ndc("kcm_pulseaudio", "Mute audio stream", "Mute %1", toolTipText) } } diff --git a/src/kcm/package/contents/ui/StreamListItem.qml b/src/kcm/package/contents/ui/StreamListItem.qml --- a/src/kcm/package/contents/ui/StreamListItem.qml +++ b/src/kcm/package/contents/ui/StreamListItem.qml @@ -79,6 +79,7 @@ MuteButton { muted: Muted onCheckedChanged: Muted = checked + toolTipText: inputText.text } VolumeSlider {}