]> git.sesse.net Git - vlc/commitdiff
Qt menus: add loadSubtitlesFile
authorJean-Philippe Andre <jpeg@via.ecp.fr>
Mon, 16 Jun 2008 16:26:46 +0000 (18:26 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 17 Jun 2008 02:58:33 +0000 (19:58 -0700)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/dialogs_provider.hpp
modules/gui/qt4/menus.cpp

index c65f8d4ddb6580d07063520b3770df3e4cab32d5..87a26b9723c28cdccb1dd2e3f2ea57d0c4bc991d 100644 (file)
@@ -529,3 +529,22 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
         break;
     }
 }
+
+void DialogsProvider::loadSubtitlesFile()
+{
+    playlist_t *p_playlist = pl_Yield( p_intf );
+    if( !p_playlist || !p_playlist->p_input )
+    {
+        msg_Err( p_intf, "cannot get input" );
+        return;
+    }
+    QString qsFile = QFileDialog::getOpenFileName(
+             NULL,
+             qtr( "Choose subtitles file" ),
+             "",
+             qtr( "Subtitles files (*.cdg *.idx *.srt *.sub *.utf);;"
+                  "All files (*)" ) );
+    if( !input_AddSubtitles( p_playlist->p_input, qtu( qsFile ), true ) )
+        msg_Warn( p_intf, "unable to load subtitles file..." );
+    pl_Release( p_playlist );
+}
index 0362d9550161d4afbe5bd2f3eee8008f70f9d8db..7d661a5f071bb35981eb71f1eea2b69a2f8f9ff2 100644 (file)
@@ -187,6 +187,8 @@ public slots:
     void openAPlaylist();
     void saveAPlaylist();
 
+    void loadSubtitlesFile();
+
     void quit();
 };
 
index a16d1db813f3b70c3f42e1cf0702e1e8287bf942..7c4ec1e19a0b00b7fe1878c8ed09d524386ef5f5 100644 (file)
@@ -455,15 +455,23 @@ QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
     if( current->isEmpty() )
     {
         ACT_ADD( current, "video-es", qtr( "Video &Track" ) );
+
+        QAction *action;
+        QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
+        action = current->addMenu( submenu );
+        action->setData( "spu-es" );
+        submenu->addAction( qfu( "Load File..." ), THEDP,
+                            SLOT( loadSubtitlesFile() ) );
+
         ACT_ADD( current, "fullscreen", qtr( "&Fullscreen" ) );
         ACT_ADD( current, "zoom", qtr( "&Zoom" ) );
         ACT_ADD( current, "deinterlace", qtr( "&Deinterlace" ) );
         ACT_ADD( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
         ACT_ADD( current, "crop", qtr( "&Crop" ) );
         ACT_ADD( current, "video-on-top", qtr( "Always &On Top" ) );
-        ACT_ADD( current, "directx-wallpaper", qtr( "&DirectX Wallpaper" ) ); /* FIXME */
-        ACT_ADD( current, "video-snapshot", qtr( "&Snapshot" ) );
-        ACT_ADD( current, "ffmpeg-pp-q", qtr( "D&ecoder" ) ); /* FIXME */
+        /* ACT_ADD( current, "directx-wallpaper", qtr( "DirectX Wallpaper" ) ); */
+        ACT_ADD( current, "video-snapshot", qtr( "Snapshot" ) );
+        /* ACT_ADD( current, "ffmpeg-pp-q", qtr( "Decoder" ) ); */
     }
 
     p_input = THEMIM->getInput();
@@ -732,7 +740,7 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
                 PUSH_SEPARATOR;
                 vlc_object_t *p_vout = ( vlc_object_t * )
                     vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
-                    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
+                VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
                 if( p_vout )
                     vlc_object_release( p_vout );
 
@@ -838,7 +846,7 @@ QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
 
         if( objects[i] == 0 )
         {
-            continue;
+            p_object = NULL;
         }
         else
         {
@@ -850,6 +858,15 @@ QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
             }
         }
 
+        /* Some specific stuff */
+        if( p_object && !strcmp( varnames[i], "spu-es" ) )
+        {
+            vlc_object_t *p_vout = ( vlc_object_t* )( vlc_object_find( p_object,
+                                        VLC_OBJECT_VOUT, FIND_ANYWHERE ) );
+            if( !p_vout )
+                continue;
+        }
+
         /* Ugly specific stuff */
         if( strstr( varnames[i], "intf-add" ) )
             UpdateItem( p_intf, menu, varnames[i], p_object, false );
@@ -923,12 +940,6 @@ void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
         return;
     }
 
-    if( !strcmp( psz_var, "spu-es" ) )
-    {
-        /* TODO: add a static entry "Load File..." */
-        return;
-    }
-
     /* Check the type of the object variable */
     if( !strcmp( psz_var, "audio-es" )
      || !strcmp( psz_var, "video-es" ) )
@@ -951,7 +962,8 @@ void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
     }
 
     /* Make sure we want to display the variable */
-    if( IsMenuEmpty( psz_var, p_object ) )  return;
+    if( menu->isEmpty() && IsMenuEmpty( psz_var, p_object ) )
+        return;
 
     /* Get the descriptive name of the variable */
     int i_ret = var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
@@ -965,6 +977,7 @@ void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
     {
         action = new QAction( TEXT_OR_VAR, menu );
         menu->addAction( action );
+        action->setData( psz_var );
     }
 
     if( i_type & VLC_VAR_HASCHOICE )
@@ -973,17 +986,15 @@ void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
         if( b_submenu )
         {
             QMenu *submenu;
-            action->setEnabled( true );
             submenu = action->menu();
             if( !submenu )
             {
                 submenu = new QMenu( menu );
                 action->setMenu( submenu );
             }
-            submenu->setEnabled( true );
 
-            if( CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0 )
-                menu->addMenu( submenu );
+            action->setEnabled(
+                   CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0 );
         }
         else
             CreateChoicesMenu( menu, psz_var, p_object, true );
@@ -1020,7 +1031,8 @@ int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
     i_type = var_Type( p_object, psz_var );
 
     /* Make sure we want to display the variable */
-    if( IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC;
+    if( submenu->isEmpty() && IsMenuEmpty( psz_var, p_object, b_root ) )
+        return VLC_EGENERIC;
 
     switch( i_type & VLC_VAR_TYPE )
     {