[vlc-devel] commit: Qt: use showSimpleOpen to open subtitles files while playing This handles multiple files selection The dialog opens the folder containing current input (Jean-Philippe Andre )

git version control git at videolan.org
Tue Jul 29 01:08:39 CEST 2008


vlc | branch: master | Jean-Philippe Andre <jpeg at via.ecp.fr> | Sun Jul 27 17:21:13 2008 -0400| [2e8db6a0f74210285b73df381cbc00684c05d0ea]

Qt: use showSimpleOpen to open subtitles files while playing This handles multiple files selection The dialog opens the folder containing current input

Signed-off-by: Christophe Mutricy <xtophe at videolan.org>

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

 modules/gui/qt4/dialogs_provider.cpp |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 22c81fe..868f208 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -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 ) );
+    }
 }




More information about the vlc-devel mailing list