[vlc-devel] [PATCH V3 18/19] qt: add VLCSmpteTC gadget

Thomas Guillem thomas at gllm.fr
Fri Sep 6 17:20:48 CEST 2019


---
 modules/gui/qt/Makefile.am         |  3 ++
 modules/gui/qt/main_interface.cpp  |  3 ++
 modules/gui/qt/util/vlcsmptetc.cpp | 50 ++++++++++++++++++++++++++++++
 modules/gui/qt/util/vlcsmptetc.hpp | 48 ++++++++++++++++++++++++++++
 4 files changed, 104 insertions(+)
 create mode 100644 modules/gui/qt/util/vlcsmptetc.cpp
 create mode 100644 modules/gui/qt/util/vlcsmptetc.hpp

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 964acf31d5..440f5e8825 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -201,6 +201,8 @@ libqt_plugin_la_SOURCES = \
 	gui/qt/util/singleton.hpp \
 	gui/qt/util/vlctick.cpp \
 	gui/qt/util/vlctick.hpp \
+	gui/qt/util/vlcsmptetc.cpp \
+	gui/qt/util/vlcsmptetc.hpp \
 	gui/qt/util/imagehelper.cpp gui/qt/util/imagehelper.hpp \
 	gui/qt/styles/seekstyle.cpp gui/qt/styles/seekstyle.hpp
 if HAVE_WIN32
@@ -312,6 +314,7 @@ nodist_libqt_plugin_la_SOURCES = \
 	gui/qt/util/searchlineedit.moc.cpp \
 	gui/qt/util/qvlcapp.moc.cpp \
 	gui/qt/util/vlctick.moc.cpp \
+	gui/qt/util/vlcsmptetc.moc.cpp \
 	gui/qt/util/validators.moc.cpp \
 	gui/qt/util/buttons/RoundButton.moc.cpp \
 	gui/qt/util/buttons/DeckButtonsLayout.moc.cpp \
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index e9bf16938f..94bf1861d0 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -334,6 +334,9 @@ void MainInterface::createMainWidget( QSettings * )
     qRegisterMetaType<VLCTick>();
     qmlRegisterUncreatableType<VLCTick>("org.videolan.vlc", 0, 1, "VLCTick", "");
 
+    qRegisterMetaType<VLCSmpteTC>();
+    qmlRegisterUncreatableType<VLCSmpteTC>("org.videolan.vlc", 0, 1, "VLCSmpteTC", "");
+
     qmlRegisterType<VideoSurface>("org.videolan.vlc", 0, 1, "VideoSurface");
 
     if (b_hasMedialibrary)
diff --git a/modules/gui/qt/util/vlcsmptetc.cpp b/modules/gui/qt/util/vlcsmptetc.cpp
new file mode 100644
index 0000000000..3077d7cfd2
--- /dev/null
+++ b/modules/gui/qt/util/vlcsmptetc.cpp
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#include "vlcsmptetc.hpp"
+
+VLCSmpteTC::VLCSmpteTC()
+    : m_tc({0,0,0,0,2,false})
+{
+}
+
+VLCSmpteTC::VLCSmpteTC(const struct vlc_player_timer_smpte_timecode &tc)
+    : m_tc(tc)
+{
+}
+
+bool VLCSmpteTC::valid() const
+{
+    return true;
+}
+
+QString VLCSmpteTC::toString() const
+{
+    return m_tc.hours == 0 ?
+        QString("%1:%2%3%4")
+            .arg(m_tc.minutes, 2, 10, QChar('0'))
+            .arg(m_tc.seconds, 2, 10, QChar('0'))
+            .arg(m_tc.drop_frame ? ";" : ":")
+            .arg(m_tc.frames, m_tc.frame_resolution, 10, QChar('0'))
+        :
+        QString("%1:%2:%3%4%5")
+            .arg(m_tc.hours, 2, 10, QChar('0'))
+            .arg(m_tc.minutes, 2, 10, QChar('0'))
+            .arg(m_tc.seconds, 2, 10, QChar('0'))
+            .arg(m_tc.drop_frame ? ";" : ":")
+            .arg(m_tc.frames, m_tc.frame_resolution, 10, QChar('0'));
+}
diff --git a/modules/gui/qt/util/vlcsmptetc.hpp b/modules/gui/qt/util/vlcsmptetc.hpp
new file mode 100644
index 0000000000..42cd6e043e
--- /dev/null
+++ b/modules/gui/qt/util/vlcsmptetc.hpp
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#ifndef VLCSMPTETC_HPP
+#define VLCSMPTETC_HPP
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <QObject>
+#include <vlc_common.h>
+#include <vlc_player.h>
+
+class VLCSmpteTC
+{
+    Q_GADGET
+public:
+    VLCSmpteTC();
+    VLCSmpteTC(const struct vlc_player_timer_smpte_timecode &);
+
+    Q_INVOKABLE bool valid() const;
+
+    /**
+     * @brief toString
+     * @return time as HH:MM:SS[:|;]FF
+     */
+    Q_INVOKABLE QString toString() const;
+
+private:
+    struct vlc_player_timer_smpte_timecode m_tc;
+};
+
+#endif // VLCSMPTETC_HPP
-- 
2.20.1



More information about the vlc-devel mailing list