Commit 608e9e6f authored by Sefa Eyeoglu's avatar Sefa Eyeoglu Committed by Nate Graham
Browse files

Make KCM look more like applet

Summary: I was looking through changes in plasma-pa and noticed, that the KCM looks very different in contrast to the applet.

Test Plan:
Checked for mute button function on all occasions (sinks, sources, applications playing, applications recording). Checked if volume slider works as expected.

{F7446909}

Reviewers: #plasma, #vdg, ngraham, GB_2

Reviewed By: #vdg, ngraham, GB_2

Subscribers: drosca, ngraham, davidedmundson, GB_2, #plasma, plasma-devel, #vdg

Tags: #plasma, #vdg

Differential Revision: https://phabricator.kde.org/D24161
parent 8b8f6530
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -135,6 +136,7 @@ PlasmaComponents.ListItem {
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)
}
......
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 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 6 of version 3 of the license.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
function name(volume, muted, prefix) {
if (!prefix) {
prefix = "audio-volume";
}
var icon = null;
var percent = volume / maxVolumeValue;
if (percent <= 0.0 || muted) {
icon = prefix + "-muted";
} else if (percent <= 0.25) {
icon = prefix + "-low";
} else if (percent <= 0.75) {
icon = prefix + "-medium";
} else {
icon = prefix + "-high";
}
return icon;
}
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2016 David Rosca <nowrep@gmail.com>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -45,7 +46,7 @@ ScrollView {
Header {
Layout.fillWidth: true
enabled: eventStreamView.count || sinkInputView.count
text: i18nd("kcm_pulseaudio", "Playback")
text: i18nd("kcm_pulseaudio", "Playback Streams")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Applications Playing Audio")
}
......@@ -62,6 +63,7 @@ ScrollView {
}
delegate: StreamListItem {
deviceModel: sinkModel
isPlayback: true
}
}
......@@ -78,13 +80,14 @@ ScrollView {
}
delegate: StreamListItem {
deviceModel: sinkModel
isPlayback: true
}
}
Header {
Layout.fillWidth: true
enabled: sourceOutputView.count > 0
text: i18nd("kcm_pulseaudio", "Recording")
text: i18nd("kcm_pulseaudio", "Recording Streams")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Applications Recording Audio")
}
......@@ -102,6 +105,7 @@ ScrollView {
delegate: StreamListItem {
deviceModel: sourceModel
isPlayback: false
}
}
}
......
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -29,74 +30,81 @@ ColumnLayout {
id: delegate
width: parent.width
property bool isPlayback: type.substring(0, 4) == "sink"
readonly property var currentPort: Ports[ActivePortIndex]
RowLayout {
Kirigami.Icon {
Layout.alignment: Qt.AlignHCenter
width: height
height: inputText.height
Layout.preferredHeight: delegateColumn.height * 0.75
Layout.preferredWidth: Layout.preferredHeight
source: IconName || "audio-card"
}
Label {
id: inputText
ColumnLayout {
id: delegateColumn
Layout.fillWidth: true
elide: Text.ElideRight
text: Description
}
Button {
text: i18n("Default device")
icon.name: "favorite"
visible: delegate.ListView.view.count > 1
checkable: true
checked: Default
onClicked: Default = true;
}
MuteButton {
muted: Muted
onCheckedChanged: Muted = checked
}
}
ColumnLayout {
width: parent.width
RowLayout {
visible: portbox.count > 1
RowLayout {
Label {
id: inputText
Layout.fillWidth: true
elide: Text.ElideRight
text: !currentPort ? Description : i18ndc("kcm_pulseaudio", "label of device items", "%1 (%2)", currentPort.description, Description)
}
Label {
text: i18nd("kcm_pulseaudio", "Port")
}
Label {
visible: portbox.count > 1
text: i18nd("kcm_pulseaudio", "Port:")
}
ComboBox {
id: portbox
readonly property var ports: Ports
Layout.fillWidth: true
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)");
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)");
}
}
items.push(text);
}
items.push(text);
model = items;
}
model = items;
}
Button {
text: i18n("Default Device")
icon.name: "favorite"
visible: delegate.ListView.view.count > 1
checkable: true
checked: Default
onClicked: Default = true;
}
}
}
VolumeSlider {}
RowLayout {
MuteButton {
Layout.topMargin: -(height - icon.height) / 2
muted: Muted
onCheckedChanged: Muted = checked
}
VolumeSlider {}
}
}
}
ListItemSeperator { view: delegate.ListView.view }
......
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -42,8 +43,8 @@ ScrollView {
Header {
Layout.fillWidth: true
enabled: sinks.count > 0
text: i18nd("kcm_pulseaudio", "Outputs")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Output Devices Available")
text: i18nd("kcm_pulseaudio", "Playback Devices")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Playback Devices Available")
}
ListView {
......@@ -54,14 +55,16 @@ ScrollView {
interactive: false
spacing: units.smallSpacing * 2
model: sinkModel
delegate: DeviceListItem {}
delegate: DeviceListItem {
isPlayback: true
}
}
Header {
Layout.fillWidth: true
enabled: sources.count > 0
text: i18nd("kcm_pulseaudio", "Inputs")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Input Devices Available")
text: i18nd("kcm_pulseaudio", "Recording Devices")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Recording Devices Available")
}
ListView {
......@@ -71,7 +74,9 @@ ScrollView {
Layout.margins: units.gridUnit / 2
interactive: false
model: sourceModel
delegate: DeviceListItem {}
delegate: DeviceListItem {
isPlayback: false
}
}
}
}
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -19,14 +20,18 @@
*/
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Controls 2.5 as QQC2
import "../code/icon.js" as Icon
Button {
QQC2.ToolButton {
property bool muted: true
iconName: 'audio-volume-muted'
tooltip: i18nd("kcm_pulseaudio", "Mute audio")
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
}
}
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -30,6 +31,7 @@ ColumnLayout {
property alias deviceModel: deviceComboBox.model
readonly property bool isEventStream: Name == "sink-input-by-media-role:event"
property bool isPlayback: type.substring(0, 4) == "sink"
width: parent.width
......@@ -39,7 +41,7 @@ ColumnLayout {
Kirigami.Icon {
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: delegateColumn.height * 0.60
Layout.preferredHeight: delegateColumn.height * 0.75
Layout.preferredWidth: Layout.preferredHeight
source: IconName || "unknown"
}
......@@ -71,14 +73,16 @@ ColumnLayout {
Layout.preferredWidth: delegate.width / 3
visible: !isEventStream && count > 1
}
}
RowLayout {
MuteButton {
muted: Muted
onCheckedChanged: Muted = checked
}
}
VolumeSlider {}
VolumeSlider {}
}
}
}
......
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -20,14 +21,14 @@
import QtQuick 2.4
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.0
import QtQuick.Controls 2.5 as QQC2
import org.kde.plasma.private.volume 0.1
RowLayout {
Layout.bottomMargin: hundredPercentLabel.height
Slider {
QQC2.Slider {
id: slider
// Helper properties to allow async slider updates.
......@@ -40,6 +41,8 @@ RowLayout {
Layout.fillWidth: true
from: PulseAudio.MinimalVolume
to: PulseAudio.MaximalVolume
// TODO: implement a way to hide tickmarks
// stepSize: to / (PulseAudio.MaximalVolume / PulseAudio.NormalVolume * 100.0)
visible: HasVolume
enabled: VolumeWritable
opacity: Muted ? 0.5 : 1
......@@ -77,12 +80,12 @@ RowLayout {
}
}
Label {
QQC2.Label {
id: hundredPercentLabel
readonly property real hundredPos: (slider.width / slider.maximumValue) * PulseAudio.NormalVolume
readonly property real hundredPos: (slider.width / slider.to) * PulseAudio.NormalVolume
z: slider.z - 1
x: (Qt.application.layoutDirection == Qt.RightToLeft ? slider.width - hundredPos : hundredPos) - width / 2
y: slider.height / 1.2
y: slider.height
opacity: 0.5
font.pixelSize: slider.height / 2.2
text: i18nd("kcm_pulseaudio", "100%")
......@@ -95,7 +98,7 @@ RowLayout {
}
}
Label {
QQC2.Label {
id: percentText
readonly property real value: PulseObject.volume > slider.maximumValue ? PulseObject.volume : slider.value
Layout.alignment: Qt.AlignHCenter
......
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
......@@ -31,6 +32,7 @@ Kirigami.Page {
title: kcm.name
property QtObject sinkModel: SinkModel { }
property QtObject sourceModel: SourceModel { }
property int maxVolumeValue: PulseAudio.NormalVolume // the applet supports changing this value. We will just assume 65536 (100%)
ConfigModule.quickHelp: i18nd("kcm_pulseaudio", "This module allows configuring the Pulseaudio sound subsystem.")
implicitHeight: Kirigami.Units.gridUnit * 28
......
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