[vlc-commits] Qt: Subtitles menu

Jean-Baptiste Kempf git at videolan.org
Tue Apr 16 03:28:22 CEST 2013


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Apr 16 03:05:20 2013 +0200| [9ea4f58e65a7cde1ca537a89cb978a7d4becfd61] | committer: Jean-Baptiste Kempf

Qt: Subtitles menu

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

 modules/gui/qt4/menus.cpp |   26 +++++++++++++++-----------
 modules/gui/qt4/menus.hpp |    8 ++++++--
 2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index c154e31..0e4088f 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -321,6 +321,7 @@ void VLCMenuBar::createMenuBar( MainInterface *mi,
     BAR_DADD( NavigMenu( p_intf, bar ), qtr( "P&layback" ), 3 );
     BAR_DADD( AudioMenu( p_intf, bar ), qtr( "&Audio" ), 1 );
     BAR_DADD( VideoMenu( p_intf, bar ), qtr( "&Video" ), 2 );
+    BAR_DADD( SubtitleMenu( p_intf, bar ), qtr( "Subti&tle" ), 5 );
 
     addMenuToMainbar( ToolsMenu( bar ), qtr( "&Tools" ), bar );
 
@@ -619,16 +620,19 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
 }
 
 /* Subtitles */
-QMenu *VLCMenuBar::SubtitleMenu( QMenu *current )
+QMenu *VLCMenuBar::SubtitleMenu( intf_thread_t *, QMenu *current )
 {
-    QAction *action;
-    QMenu *submenu = new QMenu( qtr( "&Subtitle Track" ), current );
-    action = current->addMenu( submenu );
-    action->setData( "spu-es" );
-    addDPStaticEntry( submenu, qtr( "Open File..." ), "",
-                      SLOT( loadSubtitlesFile() ) );
-    submenu->addSeparator();
-    return submenu;
+    if( current->isEmpty() )
+    {
+        QAction *action;
+        QMenu *submenu = new QMenu( qtr( "&Subtitle Track" ), current );
+        action = current->addMenu( submenu );
+        action->setData( "spu-es" );
+        addDPStaticEntry( submenu, qtr( "Open File..." ), "",
+                SLOT( loadSubtitlesFile() ) );
+        submenu->addSeparator();
+    }
+    return current;
 }
 
 /**
@@ -646,7 +650,7 @@ QMenu *VLCMenuBar::VideoMenu( intf_thread_t *p_intf, QMenu *current, bool b_subt
     {
         addActionWithSubmenu( current, "video-es", qtr( "Video &Track" ) );
         if( b_subtitle)
-            SubtitleMenu( current );
+            SubtitleMenu( p_intf, current );
 
         current->addSeparator();
         /* Surface modifiers */
@@ -1036,7 +1040,7 @@ void VLCMenuBar::PopupMenu( intf_thread_t *p_intf, bool show )
         if( action->menu()->isEmpty() )
             action->setEnabled( false );
 
-        submenu = SubtitleMenu( menu );
+        submenu = SubtitleMenu( p_intf, menu );
         submenu->setTitle( qtr( "Subti&tle") );
         UpdateItem( p_intf, menu, "spu-es", VLC_OBJECT(p_input), true );
 
diff --git a/modules/gui/qt4/menus.hpp b/modules/gui/qt4/menus.hpp
index 3ccee3b..969a7cb 100644
--- a/modules/gui/qt4/menus.hpp
+++ b/modules/gui/qt4/menus.hpp
@@ -117,11 +117,14 @@ private:
     }
     static QMenu *RebuildNavigMenu( intf_thread_t *, QMenu *, bool b_keep = false );
 
-    static QMenu *VideoMenu( intf_thread_t *, QMenu *, bool b_subtitle = true );
+    static QMenu *VideoMenu( intf_thread_t *, QMenu *, bool b_subtitle = false );
     static QMenu *VideoMenu( intf_thread_t *p_intf, QWidget *parent ) {
         return VideoMenu( p_intf, new QMenu( parent ) );
     }
-    static QMenu *SubtitleMenu( QMenu *current);
+    static QMenu *SubtitleMenu( intf_thread_t *, QMenu *current);
+    static QMenu *SubtitleMenu( intf_thread_t *p_intf, QWidget *parent) {
+        return SubtitleMenu( p_intf, new QMenu( parent ) );
+    }
 
     static QMenu *AudioMenu( intf_thread_t *, QMenu * );
     static QMenu *AudioMenu( intf_thread_t *p_intf, QWidget *parent ) {
@@ -173,6 +176,7 @@ public:
             case 2: VLCMenuBar::VideoMenu( p_intf, menu ); break;
             case 3: VLCMenuBar::RebuildNavigMenu( p_intf, menu ); break;
             case 4: VLCMenuBar::ViewMenu( p_intf, menu ); break;
+            case 5: VLCMenuBar::SubtitleMenu( p_intf, menu ); break;
         }
     }
 private:



More information about the vlc-commits mailing list