[vlc-devel] [PATCH 17/18] qt: add url context menu

Prince Gupta guptaprince8832 at gmail.com
Wed Sep 23 19:40:15 CEST 2020


From: Pierre Lamot <pierre at videolabs.io>

---
 modules/gui/qt/maininterface/mainui.cpp   |  1 +
 modules/gui/qt/menus/qml_menu_wrapper.cpp | 11 +++++++++++
 modules/gui/qt/menus/qml_menu_wrapper.hpp |  9 +++++++++
 3 files changed, 21 insertions(+)

diff --git a/modules/gui/qt/maininterface/mainui.cpp b/modules/gui/qt/maininterface/mainui.cpp
index 624edb90c3..c2d5460126 100644
--- a/modules/gui/qt/maininterface/mainui.cpp
+++ b/modules/gui/qt/maininterface/mainui.cpp
@@ -184,6 +184,7 @@ void MainUI::registerQMLTypes()
         qmlRegisterType<ArtistContextMenu>( "org.videolan.medialib", 0, 1, "ArtistContextMenu" );
         qmlRegisterType<GenreContextMenu>( "org.videolan.medialib", 0, 1, "GenreContextMenu" );
         qmlRegisterType<AlbumTrackContextMenu>( "org.videolan.medialib", 0, 1, "AlbumTrackContextMenu" );
+        qmlRegisterType<URLContextMenu>( "org.videolan.medialib", 0, 1, "URLContextMenu" );
         qmlRegisterType<VideoContextMenu>( "org.videolan.medialib", 0, 1, "VideoContextMenu" );
     }
 
diff --git a/modules/gui/qt/menus/qml_menu_wrapper.cpp b/modules/gui/qt/menus/qml_menu_wrapper.cpp
index e48548b6b9..f42e31572a 100644
--- a/modules/gui/qt/menus/qml_menu_wrapper.cpp
+++ b/modules/gui/qt/menus/qml_menu_wrapper.cpp
@@ -24,6 +24,7 @@
 #include "medialibrary/mlartistmodel.hpp"
 #include "medialibrary/mlgenremodel.hpp"
 #include "medialibrary/mlalbumtrackmodel.hpp"
+#include "medialibrary/mlurlmodel.hpp"
 #include "network/networkmediamodel.hpp"
 #include "playlist/playlist_controller.hpp"
 #include "playlist/playlist_model.hpp"
@@ -158,6 +159,16 @@ void AlbumTrackContextMenu::popup(const QModelIndexList &selected, QPoint pos, Q
     BaseMedialibMenu::popup(m_model, MLAlbumTrackModel::TRACK_ID, selected, pos, options);
 }
 
+URLContextMenu::URLContextMenu(QObject* parent)
+    : BaseMedialibMenu(parent)
+{}
+
+void URLContextMenu::popup(const QModelIndexList &selected, QPoint pos, QVariantMap options)
+{
+    BaseMedialibMenu::popup(m_model, MLUrlModel::URL_ID, selected, pos, options);
+}
+
+
 VideoContextMenu::VideoContextMenu(QObject* parent)
     : QObject(parent)
 {}
diff --git a/modules/gui/qt/menus/qml_menu_wrapper.hpp b/modules/gui/qt/menus/qml_menu_wrapper.hpp
index 9af03a4a6b..369817d8ca 100644
--- a/modules/gui/qt/menus/qml_menu_wrapper.hpp
+++ b/modules/gui/qt/menus/qml_menu_wrapper.hpp
@@ -30,6 +30,7 @@ class MLAlbumModel;
 class MLGenreModel;
 class MLArtistModel;
 class MLAlbumTrackModel;
+class MLUrlModel;
 class MLVideoModel;
 class NetworkMediaModel;
 class QmlMainContext;
@@ -126,6 +127,14 @@ public slots:
     void popup(const QModelIndexList& selected, QPoint pos, QVariantMap options = {});
 };
 
+class URLContextMenu : public BaseMedialibMenu {
+    Q_OBJECT
+    SIMPLE_MENU_PROPERTY(MLUrlModel*, model, nullptr)
+public:
+    URLContextMenu(QObject* parent = nullptr);
+public slots:
+    void popup(const QModelIndexList& selected, QPoint pos, QVariantMap options = {});
+};
 
 class VideoContextMenu : public QObject {
     Q_OBJECT
-- 
2.25.1



More information about the vlc-devel mailing list