[vlc-commits] qt: Create QmlInputItem

Benjamin Arnaud git at videolan.org
Mon Mar 15 10:34:48 UTC 2021


vlc | branch: master | Benjamin Arnaud <benjamin.arnaud at videolabs.io> | Thu Mar 11 10:16:46 2021 +0100| [178513621bcbeb59b38a42b3c4ad51a186caa834] | committer: Pierre Lamot

qt: Create QmlInputItem

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=178513621bcbeb59b38a42b3c4ad51a186caa834
---

 modules/gui/qt/Makefile.am              |  2 ++
 modules/gui/qt/maininterface/mainui.cpp |  3 ++
 modules/gui/qt/util/qmlinputitem.hpp    | 59 +++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+)

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 78a9fb532c..29bfe72510 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -238,6 +238,7 @@ libqt_plugin_la_SOURCES = \
 	gui/qt/util/variables.cpp gui/qt/util/variables.hpp \
 	gui/qt/util/vlctick.cpp \
 	gui/qt/util/vlctick.hpp \
+	gui/qt/util/qmlinputitem.hpp \
 	gui/qt/widgets/native/animators.cpp \
 	gui/qt/widgets/native/animators.hpp \
 	gui/qt/widgets/native/customwidgets.cpp gui/qt/widgets/native/customwidgets.hpp \
@@ -375,6 +376,7 @@ nodist_libqt_plugin_la_SOURCES = \
 	gui/qt/util/varchoicemodel.moc.cpp \
 	gui/qt/util/variables.moc.cpp \
 	gui/qt/util/vlctick.moc.cpp \
+	gui/qt/util/qmlinputitem.moc.cpp \
 	gui/qt/widgets/native/animators.moc.cpp \
 	gui/qt/widgets/native/customwidgets.moc.cpp \
 	gui/qt/widgets/native/interface_widgets.moc.cpp \
diff --git a/modules/gui/qt/maininterface/mainui.cpp b/modules/gui/qt/maininterface/mainui.cpp
index 84b9c7a457..1b06d85678 100644
--- a/modules/gui/qt/maininterface/mainui.cpp
+++ b/modules/gui/qt/maininterface/mainui.cpp
@@ -30,6 +30,7 @@
 #include "util/systempalette.hpp"
 #include "util/sortfilterproxymodel.hpp"
 #include "util/navigation_history.hpp"
+#include "util/qmlinputitem.hpp"
 
 #include "dialogs/help/aboutmodel.hpp"
 #include "dialogs/dialogs_provider.hpp"
@@ -160,6 +161,8 @@ void MainUI::registerQMLTypes()
     qRegisterMetaType<VLCTick>();
     qmlRegisterUncreatableType<VLCTick>("org.videolan.vlc", 0, 1, "VLCTick", "");
 
+    qRegisterMetaType<QmlInputItem>();
+
     qmlRegisterType<VideoSurface>("org.videolan.vlc", 0, 1, "VideoSurface");
 
     if (m_mainInterface->hasMediaLibrary())
diff --git a/modules/gui/qt/util/qmlinputitem.hpp b/modules/gui/qt/util/qmlinputitem.hpp
new file mode 100644
index 0000000000..549847b50c
--- /dev/null
+++ b/modules/gui/qt/util/qmlinputitem.hpp
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (C) 2021 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 QMLINPUTITEM_HPP
+#define QMLINPUTITEM_HPP
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+// VLC includes
+#include <vlc_media_source.h>
+#include <vlc_cxx_helpers.hpp>
+
+// Qt includes
+#include <QObject>
+
+class QmlInputItem
+{
+    Q_GADGET
+
+    using InputItemPtr = vlc_shared_data_ptr_type(input_item_t,
+                                                  input_item_Hold,
+                                                  input_item_Release);
+
+public:
+    QmlInputItem() : item(nullptr) {}
+
+    QmlInputItem(input_item_t * item, bool hold) : item(item, hold) {}
+
+public: // Operators
+    QmlInputItem(const QmlInputItem &)  = default;
+    QmlInputItem(QmlInputItem       &&) = default;
+
+    QmlInputItem & operator=(const QmlInputItem &)  = default;
+    QmlInputItem & operator=(QmlInputItem       &&) = default;
+
+public: // Variables
+    InputItemPtr item;
+};
+
+Q_DECLARE_METATYPE(QmlInputItem)
+
+#endif // QMLINPUTITEM_HPP



More information about the vlc-commits mailing list