[vlc-commits] [Git][videolan/vlc][master] 3 commits: qml: fix broken tooltip logic in Slider.qml

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Jul 8 21:17:21 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
4c326189 by Fatih Uzunoglu at 2023-07-08T20:59:18+00:00
qml: fix broken tooltip logic in Slider.qml

Control.pressed can not be used because it
is not necessarily a mouse press.

- - - - -
a995bf24 by Fatih Uzunoglu at 2023-07-08T20:59:18+00:00
qml: show tooltip when there is visual focus in Slider.qml

- - - - -
8c794228 by Fatih Uzunoglu at 2023-07-08T20:59:18+00:00
qml: show tooltip when there is visual focus in SliderBar.qml

- - - - -


3 changed files:

- modules/gui/qt/player/qml/PlaybackSpeed.qml
- modules/gui/qt/player/qml/SliderBar.qml
- modules/gui/qt/widgets/qml/Slider.qml


Changes:

=====================================
modules/gui/qt/player/qml/PlaybackSpeed.qml
=====================================
@@ -252,7 +252,7 @@ ColumnLayout {
             return sliderToSpeed(value).toFixed(2)
         }
 
-        tooltipFollowsMouse: true
+        toolTipFollowsMouse: true
 
         Navigation.parentItem: root
         Navigation.upItem: buttonReset


=====================================
modules/gui/qt/player/qml/SliderBar.qml
=====================================
@@ -78,13 +78,24 @@ Slider {
         //tooltip is a Popup, palette should be passed explicitly
         colorContext.palette: theme.palette
 
-        visible: control.hovered
+        visible: control.hovered || control.visualFocus
 
-        text: Player.length.scale(pos.x / control.width).formatHMS() +
-              (Player.hasChapters ?
-                   " - " + Player.chapters.getNameAtPosition(control._tooltipPosition) : "")
+        text: {
+            let _text
 
-        pos: Qt.point(sliderRectMouseArea.mouseX, 0)
+            if (sliderRectMouseArea.containsMouse)
+                _text = Player.length.scale(pos.x / control.width).formatHMS()
+            else
+                _text = Player.time.formatHMS()
+
+            if (Player.hasChapters)
+                _text += " - " + Player.chapters.getNameAtPosition(control._tooltipPosition)
+
+            return _text
+        }
+
+        pos: Qt.point(sliderRectMouseArea.containsMouse ? sliderRectMouseArea.mouseX
+                                                        : (control.visualPosition * control.width), 0)
     }
 
     Util.FSM {


=====================================
modules/gui/qt/widgets/qml/Slider.qml
=====================================
@@ -49,8 +49,9 @@ T.Slider {
 
     // when set the tooltip will follow the mouse when control is hoverred
     // else tooltip will always be shown at current value.
-    property bool tooltipFollowsMouse: false
+    property bool toolTipFollowsMouse: false
 
+    property alias toolTip: toolTip
 
     // toolTipTextProvider -> function(value)
     // arg "value" is between from and to, this is "value"
@@ -61,10 +62,8 @@ T.Slider {
         return value
     }
 
-    // on control.pressed, tooltipTracker mouse states are invalid
-    readonly property real _tooltipX: (tooltipFollowsMouse && !control.pressed)
-                                      ? tooltipTracker.mouseX
-                                      : (handle.x + handle.width / 2) // handle center
+    readonly property real _tooltipX: toolTipFollowsMouse ? hoverHandler.point.position.x
+                                                          : (handle.x + handle.width / 2) // handle center
 
     // find position under given x, can be used with Slider::valueAt()
     // x is coordinate in this control's coordinate space
@@ -127,30 +126,22 @@ T.Slider {
         }
     }
 
-    MouseArea {
-        id: tooltipTracker
+    HoverHandler {
+        id: hoverHandler
 
-        anchors.fill: parent
+        acceptedPointerTypes: PointerDevice.Mouse
 
-        acceptedButtons: Qt.NoButton
-
-        hoverEnabled: true
-
-        onPressed: {
-            mouse.accepted = false
-        }
-
-        preventStealing: true
-
-        propagateComposedEvents: true
+        enabled: true
     }
 
     PointingTooltip {
+       id: toolTip
+
        z: 1 // without this tooltips get placed below root's parent popup (if any)
 
        pos: Qt.point(control._tooltipX, control.handle.height / 2)
 
-       visible: control.pressed || tooltipTracker.containsMouse
+       visible: hoverHandler.hovered || control.visualFocus
 
        text: {
            if (!visible) return ""



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/095cdf89afb3a1d5688519400d124e544d66a012...8c7942283581a5e66d7a23eb0e23a67d2f6b0b5b

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


VideoLAN code repository instance


More information about the vlc-commits mailing list