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


Commits:
e62cfa2b by Prince Gupta at 2023-02-18T16:57:03+00:00
qml: add tooltip to Playback slider

- - - - -
999c545e by Prince Gupta at 2023-02-18T16:57:03+00:00
qml: reduce playback slider width

- - - - -


1 changed file:

- modules/gui/qt/player/qml/PlaybackSpeed.qml


Changes:

=====================================
modules/gui/qt/player/qml/PlaybackSpeed.qml
=====================================
@@ -114,11 +114,15 @@ ColumnLayout {
             slider.value = Math.min(value, slider.to)
     }
 
+    function sliderToSpeed(value) {
+        return Math.pow(2, value / 17)
+    }
+
     function _applyPlayer(value) {
         if (_update === false)
             return
 
-        value = Math.pow(2, value / 17)
+        value = sliderToSpeed(value)
 
         if (_shiftPressed === false) {
             for (var i = 0; i < _values.length; i++) {
@@ -280,15 +284,52 @@ ColumnLayout {
         }
 
         handle: Rectangle {
-            width: slider.implicitHeight
-            height: slider.implicitHeight
+            width: VLCStyle.icon_small
+            height: width
+            radius: width * .5
 
             x: slider.leftPadding + slider.visualPosition * 
(slider.availableWidth - width)
             y: slider.topPadding + slider.availableHeight / 2 - height / 2
 
-            radius: slider.implicitHeight
-
             color: root._color
+
+        }
+
+        MouseArea {
+            id: toolTipTracker
+
+            anchors.fill: parent
+
+            acceptedButtons: Qt.NoButton
+
+            hoverEnabled: true
+
+            onPressed: {
+                mouse.accepted = false
+            }
+
+            preventStealing: true
+
+            propagateComposedEvents: true
+        }
+
+        Widgets.PointingTooltip {
+           z: 1 // without this tooltips get placed below root's parent popup
+
+           property real _mouseX: toolTipTracker.mouseX
+
+           pos: Qt.point(_mouseX, slider.handle.width / 2)
+
+           visible: !slider.pressed && toolTipTracker.containsMouse
+
+           text: {
+               if (!visible) return ""
+
+               var v = slider.valueAt(slider.positionAt(_mouseX))
+               return sliderToSpeed(v).toFixed(2)
+           }
+
+           colors: root.colors
         }
 
         MouseArea {
@@ -302,6 +343,13 @@ ColumnLayout {
                 root._shiftPressed = (mouse.modifiers === Qt.ShiftModifier)
             }
         }
+
+        function positionAt(x) {
+            // find postion under x, taken from qt sources QQuickSlider.cpp
+            var contentX = x - slider.leftPadding - slider.handle.width / 2
+            var extend = slider.availableWidth - slider.handle.width
+            return x / extend
+        }
     }
 
     Item {



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/98a5b3ba8471231107e48253186543073062b197...999c545e1b0aedc7491c8d2510b7bfb74272f6e0

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/98a5b3ba8471231107e48253186543073062b197...999c545e1b0aedc7491c8d2510b7bfb74272f6e0
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to