[vlc-commits] qt: add toMinutes(), toSeconds(), and toHours() util functions to VLCTick
Fatih Uzunoglu
git at videolan.org
Fri Jul 3 14:58:59 CEST 2020
vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Sat Jun 20 00:48:44 2020 +0300| [2dec747e464bc7f0b1d9cffc007aaaec798bfe43] | committer: Pierre Lamot
qt: add toMinutes(), toSeconds(), and toHours() util functions to VLCTick
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2dec747e464bc7f0b1d9cffc007aaaec798bfe43
---
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;
};
More information about the vlc-commits
mailing list