diff --git a/applet/contents/ui/DeviceListItem.qml b/applet/contents/ui/DeviceListItem.qml index 26fb8ea..14421dd 100644 --- a/applet/contents/ui/DeviceListItem.qml +++ b/applet/contents/ui/DeviceListItem.qml @@ -1,43 +1,50 @@ /* Copyright 2014-2015 Harald Sitter This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.0 import "../code/icon.js" as Icon ListItemBase { readonly property var currentPort: Ports[ActivePortIndex] - property bool onlyOne: false draggable: false label: { - if (!currentPort) { - return Description - } else { - if (onlyOne) { - return currentPort.description - } else { - return i18nc("label of device items", "%1 (%2)", currentPort.description, Description) + if (currentPort) { + 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.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); + } + } + } } + return currentPort.description; + } else { + return Description; } } - labelOpacity: onlyOne ? 1 : 0.6 - icon: Icon.formFactorIcon(FormFactor) || IconName } diff --git a/applet/contents/ui/ListItemBase.qml b/applet/contents/ui/ListItemBase.qml index 276fb9c..96c5edf 100644 --- a/applet/contents/ui/ListItemBase.qml +++ b/applet/contents/ui/ListItemBase.qml @@ -1,378 +1,393 @@ /* Copyright 2014-2015 Harald Sitter Copyright 2019 Sefa Eyeoglu This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.4 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.draganddrop 2.0 as DragAndDrop import org.kde.plasma.private.volume 0.1 import "../code/icon.js" as Icon PlasmaComponents.ListItem { id: item - property alias label: textLabel.text - property alias labelOpacity: textLabel.opacity + property alias label: defaultButton.text property alias draggable: dragArea.enabled property alias icon: clientIcon.source property alias iconUsesPlasmaTheme: clientIcon.usesPlasmaTheme property string type checked: dropArea.containsDrag opacity: (draggedStream && draggedStream.deviceIndex == Index) ? 0.3 : 1.0 + separatorVisible: false ListView.delayRemove: dragArea.dragActive Item { width: parent.width - height: rowLayout.height + height: column.height RowLayout { id: rowLayout anchors.left: parent.left anchors.right: parent.right - anchors.rightMargin: LayoutMirroring.enabled ? 0 : units.smallSpacing - anchors.leftMargin: LayoutMirroring.enabled ? units.smallSpacing : 0 - spacing: units.smallSpacing PlasmaCore.IconItem { id: clientIcon Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter Layout.preferredHeight: column.height * 0.75 Layout.preferredWidth: Layout.preferredHeight source: "unknown" + visible: type === "sink-input" || type === "source-input" onSourceChanged: { if (!valid && source != "unknown") { source = "unknown"; } } DragAndDrop.DragArea { id: dragArea anchors.fill: parent delegate: parent mimeData { source: item } onDragStarted: { draggedStream = PulseObject; beginMoveStream(type == "sink-input" ? "sink" : "source"); } onDrop: { draggedStream = null; endMoveStream(); } MouseArea { anchors.fill: parent cursorShape: dragArea.enabled ? (pressed && pressedButtons === Qt.LeftButton ? Qt.ClosedHandCursor : Qt.OpenHandCursor) : undefined acceptedButtons: Qt.LeftButton | Qt.MiddleButton onClicked: { if (mouse.button === Qt.MiddleButton) { Muted = !Muted; } } } } } ColumnLayout { id: column - spacing: 1 + spacing: 0 RowLayout { - Layout.fillWidth: true + Layout.minimumHeight: contextMenuButton.height - PlasmaExtras.Heading { - id: textLabel - Layout.fillWidth: true - height: undefined - level: 5 - opacity: 0.6 - wrapMode: Text.NoWrap - elide: Text.ElideRight - visible: !portbox.visible + PlasmaComponents3.RadioButton { + id: defaultButton + 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: PulseObject.default ? PulseObject.default : false + visible: (type == "sink" && sinkView.model.count > 1) || (type == "source" && sourceView.model.count > 1) + onClicked: PulseObject.default = true; } - 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 + Label { + id: soloLabel + text: defaultButton.text + visible: !defaultButton.visible + elide: Text.ElideRight } Item { - visible: portbox.visible Layout.fillWidth: true } - PlasmaComponents3.ToolButton { - id: defaultButton - text: i18n("Default Device") - icon.name: PulseObject.default ? "starred-symbolic" : "non-starred-symbolic" - checkable: true - checked: PulseObject.default - visible: (type == "sink" && sinkView.model.count > 1) || (type == "source" && sourceView.model.count > 1) - onClicked: PulseObject.default = true; - } - SmallToolButton { id: contextMenuButton icon: "application-menu" checkable: true onClicked: contextMenu.show() - tooltip: i18n("Show additional options for %1", textLabel.text) + tooltip: i18n("Show additional options for %1", defaultButton.text) } } RowLayout { SmallToolButton { + id: muteButton readonly property bool isPlayback: type.substring(0, 4) == "sink" icon: Icon.name(Volume, Muted, isPlayback ? "audio-volume" : "microphone-sensitivity") onClicked: Muted = !Muted checked: Muted - tooltip: i18n("Mute %1", textLabel.text) - + tooltip: i18n("Mute %1", defaultButton.text) } PlasmaComponents.Slider { id: slider // Helper properties to allow async slider updates. // While we are sliding we must not react to value updates // as otherwise we can easily end up in a loop where value // changes trigger volume changes trigger value changes. property int volume: Volume property bool ignoreValueChange: true property bool forceRaiseMaxVolume: false readonly property bool raiseMaxVolume: forceRaiseMaxVolume || volume >= PulseAudio.NormalVolume * 1.01 Layout.fillWidth: true minimumValue: PulseAudio.MinimalVolume maximumValue: raiseMaxVolume ? PulseAudio.MaximalVolume : PulseAudio.NormalVolume stepSize: maximumValue / (maximumValue / PulseAudio.NormalVolume * 100.0) visible: HasVolume enabled: VolumeWritable opacity: Muted ? 0.5 : 1 - Accessible.name: i18nc("Accessibility data on volume slider", "Adjust volume for %1", textLabel.text) + Accessible.name: i18nc("Accessibility data on volume slider", "Adjust volume for %1", defaultButton.text) Component.onCompleted: { ignoreValueChange = false; } onVolumeChanged: { var oldIgnoreValueChange = ignoreValueChange; ignoreValueChange = true; value = Volume; ignoreValueChange = oldIgnoreValueChange; } onValueChanged: { if (!ignoreValueChange) { Volume = value; Muted = value == 0; if (!pressed) { updateTimer.restart(); } } } onPressedChanged: { if (!pressed) { // Make sure to sync the volume once the button was // released. // Otherwise it might be that the slider is at v10 // whereas PA rejected the volume change and is // still at v15 (e.g.). updateTimer.restart(); if (type == "sink") { playFeedback(Index); } } } Timer { id: updateTimer interval: 200 onTriggered: slider.value = Volume } } PlasmaComponents.Label { id: percentText readonly property real value: PulseObject.volume > slider.maximumValue ? PulseObject.volume : slider.value Layout.alignment: Qt.AlignHCenter Layout.minimumWidth: percentMetrics.advanceWidth horizontalAlignment: Qt.AlignRight text: i18nc("volume percentage", "%1%", Math.round(value / PulseAudio.NormalVolume * 100.0)) } TextMetrics { id: percentMetrics font: percentText.font text: i18nc("only used for sizing, should be widest possible string", "100%") } } } } DragAndDrop.DropArea { id: dropArea anchors.fill: parent enabled: draggedStream onDragEnter: { if (draggedStream.deviceIndex == Index) { event.ignore(); } } onDrop: { draggedStream.deviceIndex = Index; } } MouseArea { anchors { fill: parent leftMargin: clientIcon.width } acceptedButtons: Qt.MiddleButton onClicked: Muted = !Muted } } PlasmaComponents.ContextMenu { id: contextMenu visualParent: contextMenuButton placement: PlasmaCore.Types.BottomPosedLeftAlignedPopup onStatusChanged: { if (status == PlasmaComponents.DialogStatus.Closed) { contextMenuButton.checked = false; } } function newSeperator() { return Qt.createQmlObject("import org.kde.plasma.components 2.0 as PlasmaComponents; PlasmaComponents.MenuItem { separator: true }", contextMenu); } function newMenuItem() { return Qt.createQmlObject("import org.kde.plasma.components 2.0 as PlasmaComponents; PlasmaComponents.MenuItem {}", contextMenu); } function loadDynamicActions() { contextMenu.clearMenuItems(); // Raise max volume menuItem = newMenuItem(); menuItem.text = i18n("Raise maximum volume"); menuItem.checkable = true; menuItem.checked = slider.forceRaiseMaxVolume; menuItem.clicked.connect(function() { slider.forceRaiseMaxVolume = !slider.forceRaiseMaxVolume; if (!slider.forceRaiseMaxVolume && Volume > PulseAudio.NormalVolume) { Volume = PulseAudio.NormalVolume; } }); contextMenu.addMenuItem(menuItem); // Switch all streams of the relevant kind to this device - if (type == "source") { + if (type == "source" && sourceView.model.count > 1) { menuItem = newMenuItem(); menuItem.text = i18n("Record all audio via this device"); menuItem.icon = "mic-on" // or "mic-ready" // or "audio-input-microphone-symbolic" menuItem.clicked.connect(function() { PulseObject.switchStreams(); }); contextMenu.addMenuItem(menuItem); - } else if (type == "sink") { + } else if (type == "sink" && sinkView.model.count > 1) { menuItem = newMenuItem(); menuItem.text = i18n("Play all audio via this device"); menuItem.icon = "audio-on" // or "audio-ready" // or "audio-speakers-symbolic" menuItem.clicked.connect(function() { PulseObject.switchStreams(); }); contextMenu.addMenuItem(menuItem); } + // Ports + // Intentionally only shown when there are at least two available ports. + if (PulseObject.ports && PulseObject.ports.length > 1) { + contextMenu.addMenuItem(newSeperator()); + + 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); + menuItem.visible = false; + + var menuItemsPorts = []; + var availablePorts = 0; + for (var i = 0; i < PulseObject.ports.length; i++) { + var port = PulseObject.ports[i]; + if (port.availability != Port.Unavailable) { + menuItemsPorts[availablePorts] = newMenuItem(); + menuItemsPorts[availablePorts].text = port.description; + menuItemsPorts[availablePorts].checkable = true; + menuItemsPorts[availablePorts].checked = i === PulseObject.activePortIndex; + var setActivePort = function(portIndex) { + return function() { + PulseObject.activePortIndex = portIndex; + }; + }; + menuItemsPorts[availablePorts].clicked.connect(setActivePort(i)); + contextMenu.addMenuItem(menuItemsPorts[availablePorts]); + menuItemsPorts[availablePorts].visible = false; + availablePorts++; + } + } + + if (1 < availablePorts){ + menuItem.visible = true; + for (var i = 0; i < availablePorts; i++) { + menuItemsPorts[i].visible = true; + } + } + } + // Choose output / input device - // By choice only shown when there are at least two options + // Intentionally only shown when there are at least two options if ((type == "sink-input" && sinkView.model.count > 1) || (type == "source-input" && sourceView.model.count > 1)) { contextMenu.addMenuItem(newSeperator()); var menuItem = newMenuItem(); if (type == "sink-input") { menuItem.text = i18nc("Heading for a list of possible output devices (speakers, headphones, ...) to choose", "Play audio using"); } else { menuItem.text = i18nc("Heading for a list of possible input devices (built-in microphone, headset, ...) to choose", "Record audio using"); } menuItem.section = true; contextMenu.addMenuItem(menuItem); var sModel = type == "sink-input" ? sinkView.model : sourceView.model; for (var i = 0; i < sModel.count; ++i) { var data = sModel.get(i); var menuItem = newMenuItem(); menuItem.text = data.Description; menuItem.enabled = true; menuItem.checkable = true; menuItem.checked = data.Index === PulseObject.deviceIndex; var setActiveSink = function(sinkIndex) { return function() { PulseObject.deviceIndex = sinkIndex; }; }; menuItem.clicked.connect(setActiveSink(data.Index)); contextMenu.addMenuItem(menuItem); } } } function show() { loadDynamicActions(); openRelative(); } } } diff --git a/applet/contents/ui/StreamListItem.qml b/applet/contents/ui/StreamListItem.qml index e0ab47a..8b5db41 100644 --- a/applet/contents/ui/StreamListItem.qml +++ b/applet/contents/ui/StreamListItem.qml @@ -1,44 +1,31 @@ /* Copyright 2014-2015 Harald Sitter This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.private.volume 0.1 ListItemBase { - property bool onlyOne: false - - label: { - if (! Client) { - return Name - } else { - if (onlyOne) { - return Client.name - } else { - return i18nc("label of stream items", "%1 (%2)", Client.name, Name) - } - } - } - labelOpacity: onlyOne ? 1 : 0.6 + label: Client ? Client.name : Name icon: IconName iconUsesPlasmaTheme: false } diff --git a/applet/contents/ui/main.qml b/applet/contents/ui/main.qml index 246d82e..92918ab 100644 --- a/applet/contents/ui/main.qml +++ b/applet/contents/ui/main.qml @@ -1,530 +1,555 @@ /* Copyright 2014-2015 Harald Sitter This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ import QtQuick 2.2 import QtQuick.Layouts 1.0 import org.kde.plasma.core 2.1 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.private.volume 0.1 import "../code/icon.js" as Icon Item { id: main property bool volumeFeedback: Plasmoid.configuration.volumeFeedback property int maxVolumeValue: Math.round(Plasmoid.configuration.maximumVolume * PulseAudio.NormalVolume / 100.0) property int volumeStep: Math.round(Plasmoid.configuration.volumeStep * PulseAudio.NormalVolume / 100.0) property string displayName: i18n("Audio Volume") property QtObject draggedStream: null // DEFAULT_SINK_NAME in module-always-sink.c readonly property string dummyOutputName: "auto_null" Layout.minimumHeight: units.gridUnit * 8 Layout.minimumWidth: units.gridUnit * 14 Layout.preferredHeight: units.gridUnit * 21 Layout.preferredWidth: units.gridUnit * 24 Plasmoid.switchHeight: Layout.minimumHeight Plasmoid.switchWidth: Layout.minimumWidth Plasmoid.icon: paSinkModel.preferredSink && !isDummyOutput(paSinkModel.preferredSink) ? Icon.name(paSinkModel.preferredSink.volume, paSinkModel.preferredSink.muted) : Icon.name(0, true) Plasmoid.toolTipMainText: { var sink = paSinkModel.preferredSink; if (!sink || isDummyOutput(sink)) { return displayName; } if (sink.muted) { return i18n("Audio Muted"); } else { return i18n("Volume at %1%", volumePercent(sink.volume)); } } - Plasmoid.toolTipSubText: paSinkModel.preferredSink && !isDummyOutput(paSinkModel.preferredSink) ? paSinkModel.preferredSink.description : "" + Plasmoid.toolTipSubText: { + if (paSinkModel.preferredSink && !isDummyOutput(paSinkModel.preferredSink)) { + var port = paSinkModel.preferredSink.ports[paSinkModel.preferredSink.activePortIndex]; + if (port) { + return port.description + } + return paSinkModel.preferredSink.name + } + return "" + } function isDummyOutput(output) { return output && output.name === dummyOutputName; } function boundVolume(volume) { return Math.max(PulseAudio.MinimalVolume, Math.min(volume, maxVolumeValue)); } function volumePercent(volume, max) { if (!max) { max = PulseAudio.NormalVolume; } return Math.round(volume / max * 100.0); } function increaseVolume() { if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { return; } var volume = boundVolume(paSinkModel.preferredSink.volume + volumeStep); var percent = volumePercent(volume, maxVolumeValue); paSinkModel.preferredSink.muted = percent == 0; paSinkModel.preferredSink.volume = volume; osd.show(percent); playFeedback(); } function decreaseVolume() { if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { return; } var volume = boundVolume(paSinkModel.preferredSink.volume - volumeStep); var percent = volumePercent(volume, maxVolumeValue); paSinkModel.preferredSink.muted = percent == 0; paSinkModel.preferredSink.volume = volume; osd.show(percent); playFeedback(); } function muteVolume() { if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { return; } var toMute = !paSinkModel.preferredSink.muted; paSinkModel.preferredSink.muted = toMute; osd.show(toMute ? 0 : volumePercent(paSinkModel.preferredSink.volume, maxVolumeValue)); if (!toMute) { playFeedback(); } } function increaseMicrophoneVolume() { if (!paSourceModel.defaultSource) { return; } var volume = boundVolume(paSourceModel.defaultSource.volume + volumeStep); var percent = volumePercent(volume); paSourceModel.defaultSource.muted = percent == 0; paSourceModel.defaultSource.volume = volume; osd.showMicrophone(percent); } function decreaseMicrophoneVolume() { if (!paSourceModel.defaultSource) { return; } var volume = boundVolume(paSourceModel.defaultSource.volume - volumeStep); var percent = volumePercent(volume); paSourceModel.defaultSource.muted = percent == 0; paSourceModel.defaultSource.volume = volume; osd.showMicrophone(percent); } function muteMicrophone() { if (!paSourceModel.defaultSource) { return; } var toMute = !paSourceModel.defaultSource.muted; paSourceModel.defaultSource.muted = toMute; osd.showMicrophone(toMute? 0 : volumePercent(paSourceModel.defaultSource.volume)); } function playFeedback(sinkIndex) { if (!volumeFeedback) { return; } if (sinkIndex == undefined) { sinkIndex = paSinkModel.preferredSink.index; } feedback.play(sinkIndex); } SinkModel { id: paSinkModel property bool initalDefaultSinkIsSet: false onDefaultSinkChanged: { if (!defaultSink || !plasmoid.configuration.outputChangeOsd) { return; } // avoid showing a OSD on startup if (!initalDefaultSinkIsSet) { initalDefaultSinkIsSet = true; return; } var description = defaultSink.description; if (isDummyOutput(defaultSink)) { description = i18n("No output device"); } var icon = Icon.formFactorIcon(defaultSink.formFactor); if (!icon) { // Show "muted" icon for Dummy output if (isDummyOutput(defaultSink)) { icon = "audio-volume-muted"; } } if (!icon) { icon = Icon.name(defaultSink.volume, defaultSink.muted); } osd.showText(icon, description); } } SourceModel { id: paSourceModel } Plasmoid.compactRepresentation: PlasmaCore.IconItem { source: plasmoid.icon active: mouseArea.containsMouse colorGroup: PlasmaCore.ColorScope.colorGroup MouseArea { id: mouseArea property int wheelDelta: 0 property bool wasExpanded: false anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.LeftButton | Qt.MiddleButton onPressed: { if (mouse.button == Qt.LeftButton) { wasExpanded = plasmoid.expanded; } else if (mouse.button == Qt.MiddleButton) { muteVolume(); } } onClicked: { if (mouse.button == Qt.LeftButton) { plasmoid.expanded = !wasExpanded; } } onWheel: { var delta = wheel.angleDelta.y || wheel.angleDelta.x; wheelDelta += delta; // Magic number 120 for common "one click" // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop while (wheelDelta >= 120) { wheelDelta -= 120; increaseVolume(); } while (wheelDelta <= -120) { wheelDelta += 120; decreaseVolume(); } } } } GlobalActionCollection { // KGlobalAccel cannot transition from kmix to something else, so if // the user had a custom shortcut set for kmix those would get lost. // To avoid this we hijack kmix name and actions. Entirely mental but // best we can do to not cause annoyance for the user. // The display name actually is updated to whatever registered last // though, so as far as user visible strings go we should be fine. // As of 2015-07-21: // componentName: kmix // actions: increase_volume, decrease_volume, mute name: "kmix" displayName: main.displayName GlobalAction { objectName: "increase_volume" text: i18n("Increase Volume") shortcut: Qt.Key_VolumeUp onTriggered: increaseVolume() } GlobalAction { objectName: "decrease_volume" text: i18n("Decrease Volume") shortcut: Qt.Key_VolumeDown onTriggered: decreaseVolume() } GlobalAction { objectName: "mute" text: i18n("Mute") shortcut: Qt.Key_VolumeMute onTriggered: muteVolume() } GlobalAction { objectName: "increase_microphone_volume" text: i18n("Increase Microphone Volume") shortcut: Qt.Key_MicVolumeUp onTriggered: increaseMicrophoneVolume() } GlobalAction { objectName: "decrease_microphone_volume" text: i18n("Decrease Microphone Volume") shortcut: Qt.Key_MicVolumeDown onTriggered: decreaseMicrophoneVolume() } GlobalAction { objectName: "mic_mute" text: i18n("Mute Microphone") shortcut: Qt.Key_MicMute onTriggered: muteMicrophone() } } VolumeOSD { id: osd } VolumeFeedback { id: feedback } + PlasmaCore.Svg { + id: lineSvg + imagePath: "widgets/line" + } + Plasmoid.fullRepresentation: ColumnLayout { spacing: units.smallSpacing Layout.preferredHeight: main.Layout.preferredHeight Layout.preferredWidth: main.Layout.preferredWidth function beginMoveStream(type, stream) { if (type == "sink") { sourceView.visible = false; - sourceViewHeader.visible = false; } else if (type == "source") { sinkView.visible = false; - sinkViewHeader.visible = false; } + devicesLine.visible = false; tabBar.currentTab = devicesTab; } function endMoveStream() { tabBar.currentTab = streamsTab; sourceView.visible = true; - sourceViewHeader.visible = true; + devicesLine.visible = true; sinkView.visible = true; - sinkViewHeader.visible = true; } RowLayout { spacing: units.smallSpacing Layout.fillWidth: true PlasmaComponents.TabBar { id: tabBar Layout.fillWidth: true activeFocusOnTab: true PlasmaComponents.TabButton { id: devicesTab text: i18n("Devices") } PlasmaComponents.TabButton { id: streamsTab text: i18n("Applications") } } - - PlasmaComponents.ToolButton { - Layout.alignment: Qt.AlignBottom - tooltip: plasmoid.action("configure").text - iconName: "configure" - Accessible.name: tooltip - onClicked: { - plasmoid.action("configure").trigger(); - } - } } PlasmaExtras.ScrollArea { id: scrollView; Layout.fillWidth: true Layout.fillHeight: true horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff flickableItem.boundsBehavior: Flickable.StopAtBounds; //our scroll isn't a list of delegates, all internal items are tab focussable, making this redundant activeFocusOnTab: false Item { width: streamsView.visible ? streamsView.width : devicesView.width height: streamsView.visible ? streamsView.height : devicesView.height ColumnLayout { 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 - Header { - Layout.fillWidth: true - visible: sinkInputView.count > 0 && !streamsView.simpleMode - text: i18n("Playback Streams") - } ListView { id: sinkInputView Layout.fillWidth: true Layout.minimumHeight: contentHeight Layout.maximumHeight: contentHeight model: PulseObjectFilterModel { filters: [ { role: "VirtualStream", value: false } ] sourceModel: SinkInputModel {} } boundsBehavior: Flickable.StopAtBounds; delegate: StreamListItem { type: "sink-input" draggable: sinkView.count > 1 - onlyOne: streamsView.simpleMode } } - Header { - Layout.fillWidth: true - visible: sourceOutputView.count > 0 && !streamsView.simpleMode - text: i18n("Recording Streams") + PlasmaCore.SvgItem { + elementId: "horizontal-line" + Layout.preferredWidth: scrollView.viewport.width - units.smallSpacing * 4 + Layout.preferredHeight: naturalSize.height + Layout.leftMargin: units.smallSpacing * 2 + Layout.rightMargin: units.smallSpacing * 2 + Layout.topMargin: units.smallSpacing + svg: lineSvg + visible: sinkInputView.model.count > 0 && sourceOutputView.model.count > 0 } + ListView { id: sourceOutputView Layout.fillWidth: true Layout.minimumHeight: contentHeight Layout.maximumHeight: contentHeight model: PulseObjectFilterModel { filters: [ { role: "VirtualStream", value: false } ] sourceModel: SourceOutputModel {} } boundsBehavior: Flickable.StopAtBounds; delegate: StreamListItem { type: "source-input" draggable: sourceView.count > 1 - onlyOne: streamsView.simpleMode } } } 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 + spacing: 0 - Header { - id: sinkViewHeader - Layout.fillWidth: true - visible: sinkView.count > 0 && !devicesView.simpleMode - text: i18n("Playback Devices") - } ListView { id: sinkView Layout.fillWidth: true Layout.minimumHeight: contentHeight Layout.maximumHeight: contentHeight + spacing: 0 model: PlasmaCore.SortFilterModel { sortRole: "SortByDefault" sortOrder: Qt.DescendingOrder sourceModel: paSinkModel filterCallback: function (source_row, value) { var idx = sourceModel.index(source_row, 0); if (sourceModel.data(idx, sourceModel.role("Name")) === dummyOutputName) { return false; } return true; } } boundsBehavior: Flickable.StopAtBounds; delegate: DeviceListItem { type: "sink" - onlyOne: devicesView.simpleMode } } - Header { - id: sourceViewHeader - Layout.fillWidth: true - visible: sourceView.count > 0 && !devicesView.simpleMode - text: i18n("Recording Devices") + PlasmaCore.SvgItem { + id: devicesLine + elementId: "horizontal-line" + Layout.preferredWidth: scrollView.viewport.width - units.smallSpacing * 4 + Layout.leftMargin: units.smallSpacing * 2 + Layout.rightMargin: Layout.leftMargin + Layout.topMargin: units.smallSpacing + svg: lineSvg + visible: sinkView.model.count > 0 && sourceView.model.count > 0 && (sinkView.model.count > 1 || sourceView.model.count > 1) } + ListView { id: sourceView Layout.fillWidth: true Layout.minimumHeight: contentHeight Layout.maximumHeight: contentHeight model: PulseObjectFilterModel { sortRole: "SortByDefault" sortOrder: Qt.DescendingOrder sourceModel: paSourceModel } boundsBehavior: Flickable.StopAtBounds; delegate: DeviceListItem { type: "source" - onlyOne: devicesView.simpleMode } } } PlasmaExtras.Heading { level: 4 opacity: 0.8 width: parent.width height: scrollView.height visible: streamsView.visible && !sinkInputView.count && !sourceOutputView.count text: i18n("No applications playing or recording audio") wrapMode: Text.WordWrap verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } PlasmaExtras.Heading { level: 4 opacity: 0.8 width: parent.width height: scrollView.height visible: devicesView.visible && !sinkView.count && !sourceView.count text: i18n("No output or input devices found") wrapMode: Text.WordWrap verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } } } + + PlasmaCore.SvgItem { + elementId: "horizontal-line" + Layout.fillWidth: true + Layout.topMargin: 0 - units.smallSpacing / 2 + Layout.leftMargin: 0 - units.smallSpacing * 1.5 + Layout.rightMargin: Layout.leftMargin + svg: lineSvg + } + + RowLayout { + + Item { + Layout.fillWidth: true + } + + PlasmaComponents.ToolButton { + tooltip: plasmoid.action("configure").text + iconName: "configure" + Accessible.name: tooltip + onClicked: plasmoid.action("configure").trigger() + } + } } Component.onCompleted: { MicrophoneIndicator.init(); } }