]> git.sesse.net Git - vlc/commitdiff
Qt: use showSimpleOpen to open subtitles files while playing This handles multiple...
authorJean-Philippe Andre <jpeg@via.ecp.fr>
Sun, 27 Jul 2008 21:21:13 +0000 (17:21 -0400)
committerChristophe Mutricy <xtophe@videolan.org>
Mon, 28 Jul 2008 23:10:08 +0000 (00:10 +0100)
Signed-off-by: Christophe Mutricy <xtophe@videolan.org>
modules/gui/qt4/dialogs_provider.cpp

index 22c81fed2e22d0750028ec104c13bfb6a62ef909..868f2082d1acf0bdcffe3feb94159498e0e51952 100644 (file)
@@ -601,12 +601,24 @@ void DialogsProvider::loadSubtitlesFile()
     input_thread_t *p_input = THEMIM->getInput();
     if( !p_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_input, qtu( qsFile ), true ) )
-        msg_Warn( p_intf, "unable to load subtitles file..." );
+    input_item_t *p_item = input_GetItem( p_input );
+    if( !p_item )
+        return;
+    char *path = input_item_GetURI( p_item );
+    if( !path )
+        path = strdup( "" );
+    char *sep = strrchr( path, DIR_SEP_CHAR );
+    if( sep )
+        *sep = '\0';
+    QStringList qsl = showSimpleOpen( qtr( "Open subtitles file" ),
+                                      EXT_FILTER_SUBTITLE,
+                                      path );
+    free( path );
+    QString qsFile;
+    foreach( qsFile, qsl )
+    {
+        if( !input_AddSubtitles( p_input, qtu( qsFile ), true ) )
+            msg_Warn( p_intf, "unable to load subtitles from '%s'",
+                      qtu( qsFile ) );
+    }
 }