[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: add `VLCTick::isSubHour()`

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Jan 5 12:06:55 UTC 2025



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
d924f315 by Fatih Uzunoglu at 2025-01-05T11:50:32+00:00
qt: add `VLCTick::isSubHour()`

- - - - -
b86023a8 by Fatih Uzunoglu at 2025-01-05T11:50:32+00:00
qml: consider hour long media for displaying the time in control bar

- - - - -


3 changed files:

- modules/gui/qt/player/qml/ControlBar.qml
- modules/gui/qt/util/vlctick.cpp
- modules/gui/qt/util/vlctick.hpp


Changes:

=====================================
modules/gui/qt/player/qml/ControlBar.qml
=====================================
@@ -102,7 +102,19 @@ T.Pane {
         id: timeTextMetrics
         font.pixelSize: (textPosition === ControlBar.TimeTextPosition.LeftRightSlider) ? VLCStyle.fontSize_small
                                                                                        : VLCStyle.fontSize_normal
-        text: "00--00" // Some extra space to compensate non-monospaced fonts.
+        text: {
+            // This text metrics is used for both the time and length, as we want them to have the same width.
+            // Length might not be reported in some cases, for that reason we should check both and use the bigger one.
+            let t
+            const time = Player.time
+            const length = Player.length
+            if (time > length)
+                t = time
+            else
+                t = length
+            // Some extra space to compensate non-monospaced fonts ("-" takes more space than ":", double "-" for guarantee)
+            return t.isSubHour() ? "00--00" : "00--00--00"
+        }
     }
 
     background: Rectangle {


=====================================
modules/gui/qt/util/vlctick.cpp
=====================================
@@ -55,6 +55,11 @@ bool VLCTick::isSubSecond() const
     return (MS_FROM_VLC_TICK(m_ticks) < 1000);
 }
 
+bool VLCTick::isSubHour() const
+{
+    return (SEC_FROM_VLC_TICK(m_ticks) < 3600);
+}
+
 QString VLCTick::formatHMS(int formatFlags) const
 {
     if (m_ticks == VLC_TICK_INVALID)


=====================================
modules/gui/qt/util/vlctick.hpp
=====================================
@@ -44,6 +44,8 @@ public:
 
     Q_INVOKABLE bool isSubSecond() const;
 
+    Q_INVOKABLE bool isSubHour() const;
+
     /**
      * @brief formatHMS
      * @param formatFlags flags to specialize formatting, default is SubSecondFormattedAsMS for legacy reasons



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7d480a5d86446b6515a375e080daa809e077f96f...b86023a8865cf76b572d8070433bff9e82ade029

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7d480a5d86446b6515a375e080daa809e077f96f...b86023a8865cf76b572d8070433bff9e82ade029
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