[vlc-devel] [PATCH 02/23] qt: add toMinutes(), toSeconds(), and toHours() util functions to VLCTick

Fatih Uzunoglu fuzun54 at outlook.com
Thu Jul 2 15:21:47 CEST 2020


---
 modules/gui/qt/util/vlctick.cpp | 28 ++++++++++++++++++++++++++++
 modules/gui/qt/util/vlctick.hpp |  4 ++++
 2 files changed, 32 insertions(+)

diff --git a/modules/gui/qt/util/vlctick.cpp b/modules/gui/qt/util/vlctick.cpp
index 43667f18ac..ed7b0cec88 100644
--- a/modules/gui/qt/util/vlctick.cpp
+++ b/modules/gui/qt/util/vlctick.cpp
@@ -47,6 +47,7 @@ QString VLCTick::toString() const
     int sec = t_sec % 60;
     int min = (t_sec / 60) % 60;
     int hour = t_sec / 3600;
+
     if (hour == 0)
         return QString("%1:%2")
                 .arg(min, 2, 10, QChar('0'))
@@ -62,3 +63,30 @@ VLCTick VLCTick::scale(float scalar) const
 {
     return VLCTick(m_ticks*scalar);
 }
+
+int VLCTick::toSeconds() const
+{
+    if (m_ticks == VLC_TICK_INVALID)
+        return 0;
+
+    int64_t t_sec = SEC_FROM_VLC_TICK(m_ticks);
+    return t_sec;
+}
+
+int VLCTick::toMinutes() const
+{
+    if (m_ticks == VLC_TICK_INVALID)
+        return 0;
+
+    int64_t t_sec = SEC_FROM_VLC_TICK(m_ticks);
+    return (t_sec / 60);
+}
+
+int VLCTick::toHours() const
+{
+    if (m_ticks == VLC_TICK_INVALID)
+        return 0;
+
+    int64_t t_sec = SEC_FROM_VLC_TICK(m_ticks);
+    return (t_sec / 3600);
+}
diff --git a/modules/gui/qt/util/vlctick.hpp b/modules/gui/qt/util/vlctick.hpp
index bcaa899945..20853984ed 100644
--- a/modules/gui/qt/util/vlctick.hpp
+++ b/modules/gui/qt/util/vlctick.hpp
@@ -44,6 +44,10 @@ public:
     Q_INVOKABLE QString toString() const;
     Q_INVOKABLE VLCTick scale(float) const;
 
+    Q_INVOKABLE int toMinutes() const;
+    Q_INVOKABLE int toSeconds() const;
+    Q_INVOKABLE int toHours()   const;
+
 private:
     vlc_tick_t m_ticks;
 };
-- 
2.25.1



More information about the vlc-devel mailing list