[vlc-devel] [PATCH 18/21] qml: adjust volume fast with right click in VolumeWidget

Fatih Uzunoglu fuzun54 at outlook.com
Sat Nov 7 17:53:37 CET 2020


Easy volume adjustment with right click. It has three steps: 0%, 50%, 100%, 125%.
---
 modules/gui/qt/player/qml/VolumeWidget.qml | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/player/qml/VolumeWidget.qml b/modules/gui/qt/player/qml/VolumeWidget.qml
index ba54380566..7afa2e9858 100644
--- a/modules/gui/qt/player/qml/VolumeWidget.qml
+++ b/modules/gui/qt/player/qml/VolumeWidget.qml
@@ -170,14 +170,31 @@ FocusScope{
                     anchors.verticalCenter: parent.verticalCenter
                     hoverEnabled: true
 
+                    acceptedButtons: Qt.LeftButton | Qt.RightButton
+
                     onPressed: function (event) {
                         volControl.forceActiveFocus()
-                        volControl.value = volControl.maxvolpos * event.x / (volControl.width)
+
+                        positionChanged(event)
                     }
+
                     onPositionChanged: function (event) {
+                        if (sliderMouseArea.pressedButtons === Qt.RightButton) {
+                            if (sliderMouseArea.mouseX < sliderMouseArea.width * volControl.fullvolpos / 4)
+                                volControl.value = 0
+                            else if (sliderMouseArea.mouseX < sliderMouseArea.width * volControl.fullvolpos * 3 / 4)
+                                volControl.value = 0.5
+                            else if (sliderMouseArea.mouseX >= sliderMouseArea.width)
+                                volControl.value = 1.25
+                            else
+                                volControl.value = 1
+                            return
+                        }
+
                         if(pressed)
                             volControl.value = volControl.maxvolpos * event.x / (volControl.width)
                     }
+
                     onWheel: {
                         if(wheel.angleDelta.y > 0)
                             volControl.increase()
@@ -185,6 +202,7 @@ FocusScope{
                             volControl.decrease()
                     }
                 }
+
                 Rectangle {
                     id: filled
                     width: volControl.visualPosition * sliderBg.width
-- 
2.25.1



More information about the vlc-devel mailing list