Commit c7adaf8a authored by Oliver Beard's avatar Oliver Beard Committed by Nate Graham
Browse files

applets/mediacontroller: Add configurability for changing volume step on icon scroll

This merge request brings the applet in line with the volume control applet's behavior,
adding configurability for changing the volume step and defaulting to 5%. Before, this
was not configurable and used a hardcoded step of 3%. Code for this was borrowed from
plasma/plasma-pa/applet with copyright headers left intact.
parent 82b2581b
Pipeline #187017 passed with stage
in 6 minutes and 11 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"
}
}
<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=""/>
<group name="General">
<entry name="volumeStep" type="Int">
<default>5</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
Kirigami.FormLayout {
property alias cfg_volumeStep: volumeStep.value
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);
}
}
}
......@@ -71,6 +71,8 @@ Item {
readonly property var loopStatus: !root.noPlayer && typeof mpris2Source.currentData.LoopStatus === "string"
? mpris2Source.currentData.LoopStatus : undefined
readonly property int volumePercentStep: Plasmoid.configuration.volumeStep
Plasmoid.switchWidth: PlasmaCore.Units.gridUnit * 14
Plasmoid.switchHeight: PlasmaCore.Units.gridUnit * 10
Plasmoid.icon: "media-playback-playing"
......@@ -174,7 +176,7 @@ Item {
onWheel: {
var service = mpris2Source.serviceForSource(mpris2Source.current)
var operation = service.operationDescription("ChangeVolume")
operation.delta = (wheel.angleDelta.y / 120) * 0.03
operation.delta = (wheel.angleDelta.y / 120) * (volumePercentStep / 100)
operation.showOSD = true
service.startOperationCall(operation)
}
......
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