]> git.sesse.net Git - vlc/commitdiff
Qt: correctly split options and escape ':' so if your dshow devices or your subtitle...
authorJean-Baptiste Kempf <jb@videolan.org>
Sun, 15 Mar 2009 16:57:37 +0000 (17:57 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 15 Mar 2009 17:21:43 +0000 (18:21 +0100)
modules/gui/qt4/components/open_panels.cpp
modules/gui/qt4/dialogs/open.cpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/util/qt_dirs.hpp

index 4c2fcd3a5b7c68c671708fee8cb064f214ca74d0..04e776b266b7ec828071e3761c35ece95ec803a7 100644 (file)
@@ -192,7 +192,7 @@ void FileOpenPanel::updateMRL()
         fileList << ui.fileListWidg->item( i )->text();
 
     if( ui.subCheckBox->isChecked() &&  !ui.subInput->text().isEmpty() ) {
-        mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
+        mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) );
         int align = ui.alignSubComboBox->itemData(
                     ui.alignSubComboBox->currentIndex() ).toInt();
         mrl.append( " :subsdec-align=" + QString().setNum( align ) );
@@ -1057,8 +1057,10 @@ void CaptureOpenPanel::updateMRL()
         break;
     case DSHOW_DEVICE:
         fileList << "dshow://";
-        mrl+= " :dshow-vdev=" + QString("%1").arg( vdevDshowW->getValue() );
-        mrl+= " :dshow-adev=" + QString("%1").arg( adevDshowW->getValue() );
+        mrl+= " :dshow-vdev=" +
+            colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
+        mrl+= " :dshow-adev=" +
+            colon_escape( QString("%1").arg( adevDshowW->getValue() ) );
         if( dshowVSizeLine->isModified() )
             mrl += " :dshow-size=" + dshowVSizeLine->text();
         break;
@@ -1252,7 +1254,7 @@ void CaptureOpenPanel::advancedDialog()
                 case CONFIG_ITEM_FILE:
                 case CONFIG_ITEM_DIRECTORY:
                 case CONFIG_ITEM_MODULE:
-                    tempMRL += QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
+                    tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
                     break;
                 case CONFIG_ITEM_INTEGER:
                     tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
index 1646093e36dcf4b9a6c625e52f1781ac43e92328..db1e67f67996f1a634c892c7619a5a5b20fafc5a 100644 (file)
@@ -30,6 +30,7 @@
 #include "dialogs_provider.hpp"
 
 #include "recents.hpp"
+#include "util/qt_dirs.hpp"
 
 #include <QTabWidget>
 #include <QGridLayout>
@@ -352,12 +353,12 @@ void OpenDialog::finish( bool b_enqueue = false )
         if( i == 0 )
         {
             /* Take options from the UI, not from what we stored */
-            QStringList optionsList = ui.advancedLineInput->text().split( ":" );
+            QStringList optionsList = ui.advancedLineInput->text().split( " :" );
 
             /* Insert options */
             for( int j = 0; j < optionsList.size(); j++ )
             {
-                QString qs = optionsList[j].trimmed();
+                QString qs = colon_unescape( optionsList[j] );
                 if( !qs.isEmpty() )
                 {
                     input_item_AddOption( p_input, qtu( qs ),
index 2c95d90f3967cbb1377113baf29aeca4ad9a148e..0adf974de9bb1ae55935d9c7bc7d50b1732a4cd7 100644 (file)
@@ -611,7 +611,7 @@ void DialogsProvider::streamingDialog( QWidget *parent,
         /* Add normal Options */
         for( int j = 0; j < options.size(); j++ )
         {
-            QString qs = options[j].trimmed();
+            QString qs = colon_unescape( options[j] );
             if( !qs.isEmpty() )
             {
                 input_item_AddOption( p_input, qtu( qs ),
index c2af9ceb2217f900c49d5d5f9670408881d0694d..113eb0d5c63310b1c2c77182f5ba2ec03f5c7026 100644 (file)
@@ -47,5 +47,13 @@ static inline QString removeTrailingSlash( QString s )
 
 #define toNativeSepNoSlash( a ) toNativeSeparators( removeTrailingSlash( a ) )
 
+static inline QString colon_escape( QString s )
+{
+    return s.replace( ":", "\\:" );
+}
+static inline QString colon_unescape( QString s )
+{
+    return s.replace( "\\:", ":" ).trimmed();
+}
 #endif