Commit 586fb5c3 authored by Bharadwaj Raju's avatar Bharadwaj Raju Committed by Nate Graham
Browse files

Move applet settings into KCM

Makes various applet-instance-specific settings global, and now configured via
the KCM.

BUG: 440846
FIXED-IN: 5.27

Fixes teams/usability/issue-board#11
parent 7a4bcf5d
Pipeline #259877 passed with stage
in 56 seconds
/*
SPDX-FileCopyrightText: 2016 David Rosca <nowrep@gmail.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.0
import org.kde.plasma.configuration 2.0
ConfigModel {
ConfigCategory {
name: i18n("General")
icon: "plasma"
source: "ConfigGeneral.qml"
}
}
......@@ -44,6 +44,9 @@
<entry name="showVirtualDevices" type="Bool">
<default>false</default>
</entry>
<entry name="migrated" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>
/*
SPDX-FileCopyrightText: 2016 David Rosca <nowrep@gmail.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.5
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.5 as QQC2
import org.kde.kirigami 2.5 as Kirigami
import org.kde.plasma.private.volume 0.1
Kirigami.FormLayout {
property alias cfg_volumeStep: volumeStep.value
property alias cfg_volumeFeedback: volumeFeedback.checked
property alias cfg_volumeOsd: volumeOsd.checked
property alias cfg_micOsd: micOsd.checked
property alias cfg_muteOsd: muteOsd.checked
property alias cfg_outputChangeOsd: outputChangeOsd.checked
property alias cfg_showVirtualDevices: showVirtualDevices.checked
VolumeFeedback {
id: feedback
}
QQC2.SpinBox {
id: volumeStep
// So it doesn't resize itself when showing a 2 or 3-digit number
Layout.minimumWidth: Kirigami.Units.gridUnit * 3
Kirigami.FormData.label: i18n("Volume step:")
from: 1
to: 100
stepSize: 1
editable: true
textFromValue: function(value) {
return value + "%";
}
valueFromText: function(text) {
return parseInt(text);
}
}
Item {
Kirigami.FormData.isSection: true
}
QQC2.CheckBox {
id: volumeFeedback
Kirigami.FormData.label: i18n("Play audio feedback for changes to:")
text: i18n("Audio volume")
enabled: feedback.valid
}
Item {
Kirigami.FormData.isSection: true
}
QQC2.CheckBox {
id: volumeOsd
Kirigami.FormData.label: i18n("Show visual feedback for changes to:")
text: i18n("Audio volume")
}
QQC2.CheckBox {
id: micOsd
text: i18n("Microphone sensitivity")
}
QQC2.CheckBox {
id: muteOsd
text: i18n("Mute state")
}
QQC2.CheckBox {
id: outputChangeOsd
text: i18n("Default output device")
}
Item {
Kirigami.FormData.isSection: true
}
QQC2.CheckBox {
id: showVirtualDevices
Kirigami.FormData.label: i18nc("@title", "Display:")
text: i18n("Show virtual devices")
}
}
......@@ -20,11 +20,15 @@ import "../code/icon.js" as Icon
Item {
id: main
property bool volumeFeedback: Plasmoid.configuration.volumeFeedback
GlobalConfig {
id: config
}
property bool volumeFeedback: config.audioFeedback
property bool globalMute: Plasmoid.configuration.globalMute
property int currentMaxVolumePercent: plasmoid.configuration.raiseMaximumVolume ? 150 : 100
property int currentMaxVolumePercent: config.raiseMaximumVolume ? 150 : 100
property int currentMaxVolumeValue: currentMaxVolumePercent * PulseAudio.NormalVolume / 100.00
property int volumePercentStep: Plasmoid.configuration.volumeStep
property int volumePercentStep: config.volumeStep
property string displayName: i18n("Audio Volume")
property QtObject draggedStream: null
......@@ -218,7 +222,7 @@ Item {
property bool initalDefaultSinkIsSet: false
onDefaultSinkChanged: {
if (!defaultSink || !plasmoid.configuration.outputChangeOsd) {
if (!defaultSink || !config.defaultOutputDeviceOsd) {
return;
}
......@@ -402,25 +406,25 @@ Item {
id: osd
function showVolume(text) {
if (!main.Plasmoid.configuration.volumeOsd)
if (!config.volumeOsd)
return
show(text, currentMaxVolumePercent)
}
function showMute(text) {
if (!main.Plasmoid.configuration.muteOsd)
if (!config.muteOsd)
return
show(text, currentMaxVolumePercent)
}
function showMic(text) {
if (!main.Plasmoid.configuration.micOsd)
if (!config.microphoneSensitivityOsd)
return
showMicrophone(text)
}
function showMicMute(text) {
if (!main.Plasmoid.configuration.muteOsd)
if (!config.muteOsd)
return
showMicrophone(text)
}
......@@ -725,14 +729,14 @@ Item {
anchors.leftMargin: PlasmaCore.Units.smallSpacing
anchors.verticalCenter: parent.verticalCenter
checked: plasmoid.configuration.raiseMaximumVolume
checked: config.raiseMaximumVolume
KeyNavigation.backtab: contentView.currentItem.contentItem.lowerListView.itemAtIndex(contentView.currentItem.contentItem.lowerListView.count - 1)
Keys.onUpPressed: KeyNavigation.backtab.forceActiveFocus(Qt.BacktabFocusReason);
text: i18n("Raise maximum volume")
onToggled: plasmoid.configuration.raiseMaximumVolume = checked
onToggled: { config.raiseMaximumVolume = checked; config.save() }
}
}
}
......@@ -745,7 +749,7 @@ Item {
}
}
function action_openKcm() {
function action_configure() {
KQCAddons.KCMShell.openSystemSettings("kcm_pulseaudio");
}
......@@ -756,8 +760,44 @@ Item {
plasmoid.action("forceMute").checkable = true;
plasmoid.action("forceMute").checked = Qt.binding(() => globalMute);
// FIXME only while Multi-page KCMs are broken when embedded in plasmoid config
plasmoid.setAction("openKcm", i18n("&Configure Audio Devices…"), "audio-volume-high");
plasmoid.action("openKcm").visible = (KQCAddons.KCMShell.authorize("kcm_pulseaudio.desktop").length > 0);
plasmoid.setAction("showVirtualDevices", i18n("Show virtual devices"), "audio-card");
plasmoid.action("showVirtualDevices").checkable = true;
plasmoid.action("showVirtualDevices").checked = Qt.binding(() => plasmoid.configuration.showVirtualDevices);
if (KQCAddons.KCMShell.authorize("kcm_pulseaudio.desktop").length > 0) {
plasmoid.removeAction("configure");
plasmoid.setAction("configure", i18n("&Configure Audio Devices…"), "configure", "alt+d, s");
}
// migrate settings if they aren't default
// this needs to be done per instance of the applet
if (Plasmoid.configuration.migrated) {
return;
}
if (Plasmoid.configuration.volumeFeedback === false && config.audioFeedback) {
config.audioFeedback = false;
config.save();
}
if (Plasmoid.configuration.volumeStep && Plasmoid.configuration.volumeStep !== 5 && config.volumeStep === 5) {
config.volumeStep = Plasmoid.configuration.volumeStep;
config.save();
}
if (Plasmoid.configuration.raiseMaximumVolume === true && !config.raiseMaximumVolume) {
config.raiseMaximumVolume = true;
config.save();
}
if (Plasmoid.configuration.volumeOsd === false && config.volumeOsd) {
config.volumeOsd = false;
config.save();
}
if (Plasmoid.configuration.muteOsd === false && config.muteOsd) {
config.muteOsd = false;
config.save();
}
if (Plasmoid.configuration.micOsd === false && config.microphoneSensitivityOsd) {
config.microphoneSensitivityOsd = false;
config.save();
}
Plasmoid.configuration.migrated = true;
}
}
......@@ -43,6 +43,7 @@ set_property(SOURCE qml/dbus/osdService.xml APPEND PROPERTY CLASSNAME OsdService
qt_add_dbus_interface(dbus_SRCS qml/dbus/osdService.xml osdservice)
add_library(plasma-volume-declarative SHARED ${dbus_SRCS} ${cpp_SRCS} ${qml_SRCS})
kconfig_add_kcfg_files(plasma-volume-declarative GENERATE_MOC qml/globalconfig.kcfgc)
target_link_libraries(plasma-volume-declarative
Qt::Core
Qt::Gui
......@@ -51,12 +52,16 @@ target_link_libraries(plasma-volume-declarative
KF5::GlobalAccel
KF5::I18n
KF5::Notifications
KF5::ConfigCore
KF5::ConfigGui
KF5::CoreAddons
Canberra::Canberra
PkgConfig::LIBPULSE
PkgConfig::LIBPULSE_MAINLOOP
PkgConfig::GIO
)
set(PRIVATE_QML_INSTALL_DIR ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/volume)
install(TARGETS plasma-volume-declarative DESTINATION ${PRIVATE_QML_INSTALL_DIR})
install(FILES ${qml_SRCS} DESTINATION ${PRIVATE_QML_INSTALL_DIR})
......
/*
SPDX-FileCopyrightText: 2022 Bharadwaj Raju <bharadwaj.raju777@protonmail.com>
SPDX-License-Identifier: GPL-3.0-or-later
*/
import QtQuick 2.7
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.15 as Kirigami
import org.kde.plasma.private.volume 0.1
Kirigami.Page {
id: volumeControlsConfigPage
title: i18n("Volume Controls")
GlobalConfig {
id: config
}
VolumeFeedback {
id: feedback
}
ColumnLayout {
anchors.fill: parent
Kirigami.FormLayout {
wideMode: true
QQC2.CheckBox {
checked: config.raiseMaximumVolume
text: i18n("Raise maximum volume")
onToggled: { config.raiseMaximumVolume = checked; config.save() }
}
QQC2.SpinBox {
id: volumeStep
// So it doesn't resize itself when showing a 2 or 3-digit number
Layout.minimumWidth: Kirigami.Units.gridUnit * 3
Kirigami.FormData.label: i18n("Volume change step:")
value: config.volumeStep
onValueModified: { config.volumeStep = value; config.save() }
from: 1
to: 100
stepSize: 1
editable: true
textFromValue: function(value) {
return value + "%";
}
valueFromText: function(text) {
return parseInt(text);
}
}
Item {
Kirigami.FormData.isSection: true
}
QQC2.CheckBox {
id: volumeFeedback
checked: config.audioFeedback
onToggled: { config.audioFeedback = checked; config.save() }
Kirigami.FormData.label: i18n("Play audio feedback for changes to:")
text: i18n("Audio volume")
enabled: feedback.valid
}
QQC2.CheckBox {
id: volumeOsd
checked: config.volumeOsd
onToggled: { config.volumeOsd = checked; config.save() }
Kirigami.FormData.label: i18n("Show visual feedback for changes to:")
text: i18n("Audio volume")
}
QQC2.CheckBox {
id: micOsd
checked: config.microphoneSensitivityOsd
onToggled: { config.microphoneSensitivityOsd = checked; config.save() }
text: i18n("Microphone sensitivity")
}
QQC2.CheckBox {
id: muteOsd
checked: config.muteOsd
onToggled: { config.muteOsd = checked; config.save() }
text: i18n("Mute state")
}
QQC2.CheckBox {
id: outputChangeOsd
checked: config.defaultOutputDeviceOsd
onToggled: { config.defaultOutputDeviceOsd = checked; config.save() }
text: i18n("Default output device")
}
}
Item {
Layout.fillHeight: true
}
}
}
......@@ -271,6 +271,12 @@ ScrollViewKCM {
visible: (paSourceModel.count != paSourceFilterModel.count) || (paSinkModel.count != paSinkFilterModel.count)
}
Button {
text: i18n("Configure Volume Controls…")
icon.name: "configure"
onClicked: kcm.push("VolumeControlsConfig.qml")
}
Button {
id: configureButton
visible: moduleManager.settingsSupported
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2022 Bharadwaj Raju <bharadwaj.raju777@protonmail.com>
SPDX-License-Identifier: GPL-3.0-or-later
-->
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="plasmaparc" />
<group name="General">
<entry name="VolumeStep" type="Int">
<label>Percent step for changing volume.</label>
<default>5</default>
</entry>
<entry name="RaiseMaximumVolume" type="Bool">
<label>Allow raising volume over 100%.</label>
<default>false</default>
</entry>
<entry name="AudioFeedback" type="Bool">
<label>Play audio feedback when changing volume.</label>
<default>true</default>
</entry>
<entry name="VolumeOsd" type="Bool">
<label>Show OSD when changing volume.</label>
<default>true</default>
</entry>
<entry name="MicrophoneSensitivityOsd" type="Bool">
<label>Show OSD when changing microphone sensitivity.</label>
<default>true</default>
</entry>
<entry name="MuteOsd" type="Bool">
<label>Show OSD when muting/unmuting.</label>
<default>true</default>
</entry>
<entry name="DefaultOutputDeviceOsd" type="Bool">
<label>Show OSD when changing default output device.</label>
<default>true</default>
</entry>
</group>
</kcfg>
# SPDX-FileCopyrightText: 2022 Bharadwaj Raju <bharadwaj.raju777@protonmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later
File=globalconfig.kcfg
ClassName=GlobalConfig
IncludeFiles=\"qml/globalconfigskeleton.h\"
Inherits=GlobalConfigSkeleton
GenerateProperties=true
Mutators=true
Notifiers=true
ParentInConstructor=true
/*
SPDX-FileCopyrightText: 2022 Bharadwaj Raju <bharadwaj.raju777@protonmail.com>
SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <KConfigSkeleton>
#include <KConfigWatcher>
#pragma once
class GlobalConfigSkeleton : public KConfigSkeleton
{
public:
explicit GlobalConfigSkeleton(const QString &configName = QStringLiteral("plasmaparc"), QObject *parent = nullptr)
: KConfigSkeleton(configName, parent)
{
setupWatcher();
};
explicit GlobalConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = nullptr)
: KConfigSkeleton(config, parent)
{
setupWatcher();
};
~GlobalConfigSkeleton() override{};
private:
KConfigWatcher::Ptr m_configWatcher;
void setupWatcher()
{
m_configWatcher = KConfigWatcher::create(sharedConfig());
connect(m_configWatcher.data(), &KConfigWatcher::configChanged, [this]() {
load();
});
}
};
......@@ -20,6 +20,7 @@
#include "volumemonitor.h"
#include "globalactioncollection.h"
#include "globalconfig.h"
#include "listitemmenu.h"
#include "microphoneindicator.h"
#include "speakertest.h"
......@@ -60,6 +61,7 @@ void Plugin::registerTypes(const char *uri)
qmlRegisterType<VolumeOSD>(uri, 0, 1, "VolumeOSD");
qmlRegisterType<VolumeFeedback>(uri, 0, 1, "VolumeFeedback");
qmlRegisterType<SpeakerTest>(uri, 0, 1, "SpeakerTest");
qmlRegisterType<GlobalConfig>(uri, 0, 1, "GlobalConfig");
qmlRegisterSingletonType(uri, 0, 1, "PulseAudio", pulseaudio_singleton);
qmlRegisterSingletonType<MicrophoneIndicator>(uri, 0, 1, "MicrophoneIndicator", [](QQmlEngine *engine, QJSEngine *jsEngine) -> QObject * {
Q_UNUSED(engine);
......
Supports Markdown
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