[vlc-commits] qt: add function to open VLsub from player_controller

Prince Gupta git at videolan.org
Fri Nov 6 16:00:45 CET 2020


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Fri Oct  2 22:00:35 2020 +0530| [6f94e676cd72de1e727a1123903f55f17ba84082] | committer: Pierre Lamot

qt: add function to open VLsub from player_controller

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

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

 .../qt/dialogs/extensions/extensions_manager.cpp   | 25 ++++++++++++++++++++++
 .../qt/dialogs/extensions/extensions_manager.hpp   |  2 ++
 modules/gui/qt/player/player_controller.cpp        | 12 +++++++++++
 modules/gui/qt/player/player_controller.hpp        |  1 +
 4 files changed, 40 insertions(+)

diff --git a/modules/gui/qt/dialogs/extensions/extensions_manager.cpp b/modules/gui/qt/dialogs/extensions/extensions_manager.cpp
index 4f792fbdb9..8bd032e731 100644
--- a/modules/gui/qt/dialogs/extensions/extensions_manager.cpp
+++ b/modules/gui/qt/dialogs/extensions/extensions_manager.cpp
@@ -216,6 +216,31 @@ void ExtensionsManager::menu( QMenu *current )
     vlc_mutex_unlock( &p_extensions_manager->lock );
 }
 
+void ExtensionsManager::openVLsub()
+{
+    if( !isLoaded() )
+    {
+        // This case can happen: do nothing
+        return;
+    }
+
+    vlc_mutex_lock( &p_extensions_manager->lock );
+
+    extension_t *p_ext;
+    ARRAY_FOREACH( p_ext, p_extensions_manager->extensions )
+    {
+        const char *extensionName = p_ext->psz_shortdescription ? p_ext->psz_shortdescription: p_ext->psz_title;
+        if ( !extensionName || strcmp( extensionName, "VLsub" ) )
+            continue;
+
+        vlc_mutex_unlock( &p_extensions_manager->lock );
+        triggerMenu( MENU_MAP( 0, array_index_p_ext ) );
+        return;
+    }
+
+    vlc_mutex_unlock( &p_extensions_manager->lock );
+}
+
 void ExtensionsManager::triggerMenu( int id )
 {
     uint16_t i_ext = MENU_GET_EXTENSION( id );
diff --git a/modules/gui/qt/dialogs/extensions/extensions_manager.hpp b/modules/gui/qt/dialogs/extensions/extensions_manager.hpp
index ceb56c24df..fd4cd7b306 100644
--- a/modules/gui/qt/dialogs/extensions/extensions_manager.hpp
+++ b/modules/gui/qt/dialogs/extensions/extensions_manager.hpp
@@ -63,6 +63,8 @@ public:
     inline bool isUnloading() { return b_unloading; }
     void menu( QMenu *current );
 
+    void openVLsub();
+
     /** Get the extensions_manager_t if it is loaded */
     extensions_manager_t* getManager()
     {
diff --git a/modules/gui/qt/player/player_controller.cpp b/modules/gui/qt/player/player_controller.cpp
index fabb32bb0d..e219cd87aa 100644
--- a/modules/gui/qt/player/player_controller.cpp
+++ b/modules/gui/qt/player/player_controller.cpp
@@ -20,6 +20,7 @@
 # include "config.h"
 #endif
 
+#include "dialogs/extensions/extensions_manager.hpp"
 #include "player_controller.hpp"
 #include "player_controller_p.hpp"
 
@@ -1595,6 +1596,17 @@ void PlayerController::updateTime(vlc_tick_t system_now, bool forceUpdate)
     }
 }
 
+void PlayerController::openVLsub()
+{
+    Q_D(PlayerController);
+
+    const auto extensionManager = ExtensionsManager::getInstance( d->p_intf );
+    if ( !extensionManager->isLoaded() )
+        extensionManager->loadExtensions();
+
+    extensionManager->openVLsub();
+}
+
 void PlayerController::updateTimeFromTimer()
 {
     Q_D(PlayerController);
diff --git a/modules/gui/qt/player/player_controller.hpp b/modules/gui/qt/player/player_controller.hpp
index cfdc9e8a1f..8dc4ed43dd 100644
--- a/modules/gui/qt/player/player_controller.hpp
+++ b/modules/gui/qt/player/player_controller.hpp
@@ -280,6 +280,7 @@ public slots:
     void updateTimeFromTimer();
     bool canRestorePlayback() const;
     void restorePlaybackPos();
+    void openVLsub();
 
     //tracks
     TrackListModel* getVideoTracks();



More information about the vlc-commits mailing list