[vlc-devel] [PATCH 3/3] qt: improve volume slider control

Romain Vimont rom1v at videolabs.io
Wed Apr 7 16:27:06 UTC 2021


The slider has some width, which must be taken into account to compute
the volume.

This avoids to control the left of the handle near 0% but the right of
the handle near 125%. Instead, it always controls the center of the
handle.
---
 modules/gui/qt/player/qml/VolumeWidget.qml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/gui/qt/player/qml/VolumeWidget.qml b/modules/gui/qt/player/qml/VolumeWidget.qml
index 177ca6caae..6c325ae9ab 100644
--- a/modules/gui/qt/player/qml/VolumeWidget.qml
+++ b/modules/gui/qt/player/qml/VolumeWidget.qml
@@ -218,7 +218,7 @@ FocusScope{
                         }
 
                         if(pressed)
-                            volControl.value = volControl.maxvolpos * event.x / sliderMouseArea.width
+                            volControl.value = volControl.maxvolpos * (event.x - handle.width / 2) / (sliderMouseArea.width - handle.width)
                     }
 
                     onWheel: {
-- 
2.31.0



More information about the vlc-devel mailing list