[vlc-devel] [PATCH 34/38] qml: use PointingTooltip as the tooltip of SliderBar

Fatih Uzunoglu fuzun54 at outlook.com
Thu Aug 20 19:55:43 CEST 2020


---
 modules/gui/qt/player/qml/SliderBar.qml | 103 ++----------------------
 1 file changed, 8 insertions(+), 95 deletions(-)

diff --git a/modules/gui/qt/player/qml/SliderBar.qml b/modules/gui/qt/player/qml/SliderBar.qml
index fea3ed26b3..3b1e95e566 100644
--- a/modules/gui/qt/player/qml/SliderBar.qml
+++ b/modules/gui/qt/player/qml/SliderBar.qml
@@ -20,6 +20,7 @@ import QtQuick.Controls 2.4
 import QtQuick.Layouts 1.3
 import QtGraphicalEffects 1.0
 
+import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
 
 Slider {
@@ -30,6 +31,8 @@ Slider {
     property bool _isSeekPointsShown: true
     property bool isMiniplayer: false
 
+    property alias parentWindow: timeTooltip.parentWindow
+
     anchors.margins: isMiniplayer ? 0 : VLCStyle.margin_xxsmall
 
     Keys.onRightPressed: player.jumpFwd()
@@ -42,106 +45,16 @@ Slider {
         onTriggered: control._isSeekPointsShown = false
     }
 
-    Item {
+    Widgets.PointingTooltip {
         id: timeTooltip
-        property real location: sliderRectMouseArea.mouseX
-        property real position: location/control.width
-
-        width: childrenRect.width
-        height: childrenRect.height
-
-        function getX() {
-            var x = location - (timeTooltip.width / 2)
-            var diff = (x + timeTooltip.width) - (VLCStyle.appWidth)
-            var sliderRealX = mainInterfaceRect.mapFromItem(sliderRectMouseArea, sliderRectMouseArea.x, sliderRectMouseArea.y).x
-
-            if (x < -sliderRealX) {
-                arrow.diff = x
-                x = -sliderRealX
-            }
-            else if (diff > 0) {
-                arrow.diff = diff
-                x -= (diff)
-            }
-            else {
-                arrow.diff = 0
-            }
-
-            return x
-        }
 
-        y: -(childrenRect.height)
-        x: getX()
         visible: control.hovered
 
-        Item {
-            height: childrenRect.height * Math.sqrt(2)
-            width: timeIndicatorRect.width
-
-            anchors.horizontalCenter: timeIndicatorRect.horizontalCenter
-            anchors.verticalCenter: timeIndicatorRect.bottom
-            anchors.verticalCenterOffset: height / 2
-
-            clip: true
-
-            Rectangle {
-                id: arrow
-                width: VLCStyle.dp(10)
-                height: VLCStyle.dp(10)
-
-                anchors.centerIn: parent
-                anchors.verticalCenterOffset: -(parent.height / 2)
-                anchors.horizontalCenterOffset: diff
-
-                property int diff: 0
-
-                color: VLCStyle.colors.bgAlt
-
-                rotation: 45
+        text: player.length.scale(timeTooltip.position).toString() +
+              (player.hasChapters ?
+                   " - " + player.chapters.getNameAtPosition(timeTooltip.position) : "")
 
-                RectangularGlow {
-                    anchors.fill: parent
-                    glowRadius: VLCStyle.dp(2)
-                    spread: 0.2
-                    color: VLCStyle.colors.glowColor
-                }
-            }
-        }
-
-        Rectangle {
-            id: timeIndicatorRect
-            width: timeMetrics.width + VLCStyle.dp(10)
-            height: timeMetrics.height + VLCStyle.dp(5)
-
-            color: VLCStyle.colors.bgAlt
-            radius: VLCStyle.dp(6)
-
-            RectangularGlow {
-                anchors.fill: parent
-
-                glowRadius: VLCStyle.dp(2)
-                cornerRadius: parent.radius
-                spread: 0.2
-
-                color: VLCStyle.colors.glowColor
-            }
-
-            Text {
-                anchors.fill: parent
-                text: timeMetrics.text
-                color: VLCStyle.colors.text
-
-                horizontalAlignment: Text.AlignHCenter
-                verticalAlignment: Text.AlignVCenter
-
-                TextMetrics {
-                    id: timeMetrics
-                    text: player.length.scale(timeTooltip.position).toString() +
-                          (player.hasChapters ?
-                               " - " + player.chapters.getNameAtPosition(timeTooltip.position) : "")
-                }
-            }
-        }
+        mouseArea: sliderRectMouseArea
     }
 
     Connections {    
-- 
2.25.1



More information about the vlc-devel mailing list