[vlc-commits] [Git][videolan/vlc][master] 2 commits: qml: respect control height in volume widget

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Nov 19 19:37:57 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
6e73d0d3 by Fatih Uzunoglu at 2021-11-19T18:30:14+00:00
qml: respect control height in volume widget

- - - - -
99ee7a29 by Fatih Uzunoglu at 2021-11-19T18:30:14+00:00
qml: correct volume widget tooltip visibility and positioning

- - - - -


1 changed file:

- modules/gui/qt/player/qml/controlbarcontrols/VolumeWidget.qml


Changes:

=====================================
modules/gui/qt/player/qml/controlbarcontrols/VolumeWidget.qml
=====================================
@@ -39,6 +39,8 @@ FocusScope{
 
     RowLayout{
         id: volumeWidget
+
+        anchors.fill: parent
         spacing: 0
 
         Widgets.IconToolButton{
@@ -122,16 +124,6 @@ FocusScope{
                 running: false
                 repeat: false
                 interval: 1000
-
-                onRunningChanged: {
-                    if (!volumeTooltip.active)
-                        return
-
-                    if (running)
-                        volumeTooltip.visible = true
-                    else
-                        volumeTooltip.visible = Qt.binding(function() {return sliderMouseArea.containsMouse;})
-                }
             }
 
             Navigation.leftItem: volumeBtn
@@ -171,11 +163,11 @@ FocusScope{
                 active: !paintOnly
 
                 sourceComponent: Widgets.PointingTooltip {
-                    visible: sliderMouseArea.pressed || sliderMouseArea.containsMouse
+                    visible: tooltipShower.running || sliderMouseArea.pressed || sliderMouseArea.containsMouse
 
                     text: Math.round(volControl.value * 100) + "%"
 
-                    pos: Qt.point(handle.x + handle.width / 2, 0)
+                    pos: Qt.point(handle.x + handle.width / 2, handle.y)
 
                     colors: widgetfscope.colors
                 }
@@ -192,61 +184,6 @@ FocusScope{
                 radius: VLCStyle.dp(4, VLCStyle.scale)
                 color: colors.volsliderbg
 
-                MouseArea {
-                    id: sliderMouseArea
-                    anchors.fill: parent
-                    anchors.topMargin: -VLCStyle.dp(30, VLCStyle.scale)
-                    anchors.bottomMargin: anchors.topMargin
-
-                    hoverEnabled: true
-                    acceptedButtons: Qt.LeftButton | Qt.RightButton
-
-                    Component.onCompleted: {
-                        positionChanged.connect(adjustVolume)
-                        onPressed.connect(adjustVolume)
-                    }
-
-                    function adjustVolume(mouse) {
-                        if (pressedButtons === Qt.LeftButton) {
-                            // The slider itself can handle this,
-                            // but then the top&bottom margins need to be
-                            // set there instead of here. Also, if handled
-                            // there stepSize will be respected.
-                            volControl.value = volControl.maxvolpos * (mouseX - handle.width / 2)
-                                                                    / (width - handle.width)
-
-                            mouse.accepted = true
-                        } else if (pressedButtons === Qt.RightButton) {
-                            var pos = mouseX * volControl.maxvolpos / width
-                            if (pos < 0.25)
-                                volControl.value = 0
-                            else if (pos < 0.75)
-                                volControl.value = 0.5
-                            else if (pos < 1.125)
-                                volControl.value = 1
-                            else
-                                volControl.value = 1.25
-
-                            mouse.accepted = true
-                        }
-                    }
-
-                    onPressed: {
-                        if (!volControl.activeFocus)
-                            volControl.forceActiveFocus(Qt.MouseFocusReason)
-                    }
-
-                    onWheel: {
-                        var x = wheel.angleDelta.x
-                        var y = wheel.angleDelta.y
-
-                        if (x > 0 || y > 0)
-                            volControl.increase()
-                        else if (x < 0 || y < 0)
-                            volControl.decrease()
-                    }
-                }
-
                 Rectangle {
                     id: filled
                     width: volControl.visualPosition * sliderBg.width
@@ -286,6 +223,64 @@ FocusScope{
                 visible: (paintOnly || volControl.hovered || volControl.activeFocus)
                 color: volControl.sliderColor
             }
+
+            MouseArea {
+                id: sliderMouseArea
+                anchors.fill: parent
+
+                hoverEnabled: true
+                acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+                Component.onCompleted: {
+                    positionChanged.connect(adjustVolume)
+                    onPressed.connect(adjustVolume)
+                }
+
+                function adjustVolume(mouse) {
+                    if (pressedButtons === Qt.LeftButton) {
+                        // The slider itself can handle this,
+                        // but then the top&bottom margins need to be
+                        // set there instead of here. Also, if handled
+                        // there stepSize will be respected.
+                        volControl.value = volControl.maxvolpos * (mouse.x - handle.width)
+                                                                / (sliderBg.width - handle.width)
+
+                        mouse.accepted = true
+                    } else if (pressedButtons === Qt.RightButton) {
+                        var pos = mouse.x * volControl.maxvolpos / width
+                        if (pos < 0.25)
+                            volControl.value = 0
+                        else if (pos < 0.75)
+                            volControl.value = 0.5
+                        else if (pos < 1.125)
+                            volControl.value = 1
+                        else
+                            volControl.value = 1.25
+
+                        mouse.accepted = true
+                    }
+                }
+
+                onPressed: {
+                    if (!volControl.activeFocus)
+                        volControl.forceActiveFocus(Qt.MouseFocusReason)
+                }
+
+                onWheel: {
+                    var x = wheel.angleDelta.x
+                    var y = wheel.angleDelta.y
+
+                    if (x > 0 || y > 0) {
+                        volControl.increase()
+                        wheel.accepted = true
+                    } else if (x < 0 || y < 0) {
+                        volControl.decrease()
+                        wheel.accepted = true
+                    } else {
+                        wheel.accepted = false
+                    }
+                }
+            }
         }
     }
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8a0834af8fe51d19ddc8fa216cac3b5d79296fc0...99ee7a29c1671c5401f1f16ab444e723dfc5ec36

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8a0834af8fe51d19ddc8fa216cac3b5d79296fc0...99ee7a29c1671c5401f1f16ab444e723dfc5ec36
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list