[vlc-commits] qml: adjust volume fast with right click in VolumeWidget

Fatih Uzunoglu git at videolan.org
Mon Nov 16 10:04:24 CET 2020


vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Sat Aug 22 13:17:04 2020 +0300| [29c5b2d09d3a7df3241aa9c374d5a606a3f3c041] | committer: Pierre Lamot

qml: adjust volume fast with right click in VolumeWidget

Easy volume adjustment with right click. It has three steps: 0%, 100%, 125%.

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=29c5b2d09d3a7df3241aa9c374d5a606a3f3c041
---

 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



More information about the vlc-commits mailing list