[vlc-commits] qt: improve right-click volume control
Romain Vimont
git at videolan.org
Mon Apr 12 08:14:54 UTC 2021
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Wed Apr 7 18:27:04 2021 +0200| [f317d34c902c68c3192a71aba13752888a27c976] | committer: Pierre Lamot
qt: improve right-click volume control
Right-click allows to set the volume control to predefined steps (0%,
50%, 100% and 125%).
However, the last step (125%) was only reachable from the last pixel.
Instead, set to the nearest predefined value (and simplify the code for
readability).
0% 50% 100% 125%
| | | |
^^^^^---------^^^^^^^^^- (before)
^^^^^---------^^^^^^^--- (after)
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f317d34c902c68c3192a71aba13752888a27c976
---
modules/gui/qt/player/qml/VolumeWidget.qml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/modules/gui/qt/player/qml/VolumeWidget.qml b/modules/gui/qt/player/qml/VolumeWidget.qml
index 7e087495cf..67ac2ab58c 100644
--- a/modules/gui/qt/player/qml/VolumeWidget.qml
+++ b/modules/gui/qt/player/qml/VolumeWidget.qml
@@ -205,14 +205,15 @@ FocusScope{
onPositionChanged: function (event) {
if (sliderMouseArea.pressedButtons === Qt.RightButton) {
- if (sliderMouseArea.mouseX < sliderMouseArea.width * volControl.fullvolpos / 4)
+ var pos = sliderMouseArea.mouseX * volControl.maxvolpos / sliderMouseArea.width
+ if (pos < 0.25)
volControl.value = 0
- else if (sliderMouseArea.mouseX < sliderMouseArea.width * volControl.fullvolpos * 3 / 4)
+ else if (pos < 0.75)
volControl.value = 0.5
- else if (sliderMouseArea.mouseX >= sliderMouseArea.width)
- volControl.value = 1.25
- else
+ else if (pos < 1.125)
volControl.value = 1
+ else
+ volControl.value = 1.25
return
}
More information about the vlc-commits
mailing list