[vlc-devel] [PATCH 6/6] qml: add seekpoints to sliderBar

Abel Tesfaye abeltesfaye45 at gmail.com
Fri May 31 13:00:57 CEST 2019


From: Abel Tesfaye <Abeltesfaye45 at gmail.com>

fixes #22196
---
 modules/gui/qt/qml/player/SliderBar.qml | 57 +++++++++++++++++++++++--
 modules/gui/qt/qml/style/VLCColors.qml  |  2 +
 2 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt/qml/player/SliderBar.qml b/modules/gui/qt/qml/player/SliderBar.qml
index 884c00375f..f9372479ff 100644
--- a/modules/gui/qt/qml/player/SliderBar.qml
+++ b/modules/gui/qt/qml/player/SliderBar.qml
@@ -17,6 +17,7 @@
  *****************************************************************************/
 import QtQuick 2.11
 import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.3
 
 import "qrc:///style/"
 
@@ -24,12 +25,20 @@ Slider {
     id: control
     property int barHeight: 5
     property bool _isHold: false
-
+    property bool _isSeekPointsShown: true
+    
     anchors.margins: VLCStyle.margin_xxsmall
 
     Keys.onRightPressed: player.jumpFwd()
     Keys.onLeftPressed: player.jumpBwd()
 
+    Timer {
+        id: seekpointTimer
+        running: player.hasChapters && !control.hovered && _isSeekPointsShown
+        interval: 3000
+        onTriggered: control._isSeekPointsShown = false
+    }
+
     Item {
         id: timeTooltip
         property real location: 0
@@ -57,8 +66,9 @@ Slider {
             color: VLCStyle.colors.bgAlt
 
             Text {
-                anchors.centerIn: parent
-                text: (player.length.scale(timeTooltip.position).toString())
+                text: player.length.scale(timeTooltip.position).toString() +
+                      (player.hasChapters ?
+                           " - " + player.chapters.getNameAtPosition(timeTooltip.position) : "")
                 color: VLCStyle.colors.text
             }
         }
@@ -91,6 +101,9 @@ Slider {
         color: "transparent"
 
         MouseArea {
+            id: sliderRectMouseArea
+            property bool isEntered: false
+
             anchors.fill: parent
             hoverEnabled: true
 
@@ -108,6 +121,14 @@ Slider {
                 }
                 timeTooltip.location = event.x
             }
+            onEntered: {
+                if(player.hasChapters)
+                    control._isSeekPointsShown = true
+            }
+            onExited: {
+                if(player.hasChapters)
+                    seekpointTimer.restart()
+            }
         }
 
         Rectangle {
@@ -214,6 +235,36 @@ Slider {
                 rightMargin: VLCStyle.margin_xxsmall
             }
         }
+
+        RowLayout {
+            id: seekpointsRow
+            spacing: 0
+            visible: player.hasChapters
+            Repeater {
+                id: seekpointsRptr
+                model: player.chapters
+                Rectangle {
+                    id: seekpointsRect
+                    property real position: model.position
+
+                    color: VLCStyle.colors.seekpoint
+                    width: 1 * VLCStyle.scale
+                    height: control.barHeight
+                    x: sliderRect.width * seekpointsRect.position
+                }
+            }
+
+            OpacityAnimator on opacity {
+                from: 1
+                to: 0
+                running: !control._isSeekPointsShown
+            }
+            OpacityAnimator on opacity{
+                from: 0
+                to: 1
+                running: control._isSeekPointsShown
+            }
+        }
     }
 
     handle: Rectangle {
diff --git a/modules/gui/qt/qml/style/VLCColors.qml b/modules/gui/qt/qml/style/VLCColors.qml
index 9fde3274b8..8dc919bc80 100644
--- a/modules/gui/qt/qml/style/VLCColors.qml
+++ b/modules/gui/qt/qml/style/VLCColors.qml
@@ -77,6 +77,8 @@ Item {
 
     property color buffer: "#696969";
 
+    property color seekpoint: "red";
+
     property var colorSchemes: ["system", "day", "night"]
 
     state: "system"
-- 
2.21.0



More information about the vlc-devel mailing list