[vlc-devel] commit: Qt: Forgotten native separators in open panel (cosmetic) and in preferences. (Jean-Baptiste Kempf )

git version control git at videolan.org
Fri Sep 19 03:09:51 CEST 2008


vlc | branch: 0.9-bugfix | Jean-Baptiste Kempf <jb at videolan.org> | Thu Sep 18 16:15:55 2008 -0700| [d3287f0bb028f51ce81d872eafeece761273d00c] | committer: Jean-Baptiste Kempf 

Qt: Forgotten native separators in open panel (cosmetic) and in preferences.

Should repair skins options.

Remove remaining / in folder names, and use normale DIR_SEP in all platforms.

This seems to have been an issue with many people on windows.

(cherry picked from commit 3101cfaba7f7737ab822acf97684ffa1d21ddd57)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/components/open_panels.cpp         |    8 +++---
 modules/gui/qt4/components/preferences_widgets.cpp |    8 +++---
 modules/gui/qt4/dialogs/help.cpp                   |    9 +-----
 modules/gui/qt4/dialogs/sout.cpp                   |    2 +-
 modules/gui/qt4/dialogs_provider.cpp               |   26 +++++++++++--------
 modules/gui/qt4/qt4.hpp                            |    9 +++++++
 6 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index f7e1cb2..10fd23e 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -405,11 +405,11 @@ void DiscOpenPanel::updateMRL()
 
 void DiscOpenPanel::browseDevice()
 {
-    QString dir = QFileDialog::getExistingDirectory( 0,
+    QString dir = QFileDialog::getExistingDirectory( this,
             qtr( I_DEVICE_TOOLTIP ) );
-    if (!dir.isEmpty()) {
-        ui.deviceCombo->setEditText( dir );
-    }
+    if (!dir.isEmpty())
+        ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
+
     updateMRL();
 }
 
diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp
index 76db951..4f3757a 100644
--- a/modules/gui/qt4/components/preferences_widgets.cpp
+++ b/modules/gui/qt4/components/preferences_widgets.cpp
@@ -304,7 +304,7 @@ void FileConfigControl::updateField()
     QString file = QFileDialog::getOpenFileName( NULL,
                   qtr( "Select File" ), qfu( config_GetHomeDir() ) );
     if( file.isNull() ) return;
-    text->setText( file );
+    text->setText( toNativeSeparators( file ) );
 }
 
 void FileConfigControl::finish()
@@ -334,10 +334,10 @@ void DirectoryConfigControl::updateField()
                       qtr( "Select Directory" ),
                       text->text().isEmpty() ?
                         qfu( config_GetHomeDir() ) : text->text(),
-                      QFileDialog::ShowDirsOnly |
-                        QFileDialog::DontResolveSymlinks );
+                  QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
+
     if( dir.isNull() ) return;
-    text->setText( dir );
+    text->setText( toNativeSepNoSlash( dir ) );
 }
 
 #if 0
diff --git a/modules/gui/qt4/dialogs/help.cpp b/modules/gui/qt4/dialogs/help.cpp
index 811c1ca..dd52042 100644
--- a/modules/gui/qt4/dialogs/help.cpp
+++ b/modules/gui/qt4/dialogs/help.cpp
@@ -276,14 +276,9 @@ void UpdateDialog::UpdateOrDownload()
                                  qtr( "Select a directory..." ),
                                  qfu( config_GetHomeDir() ) );
 
-        if( dest_dir != "" )
+        if( !dest_dir.isEmpty() )
         {
-            /*HACK: Qt4 isn't able to change the way OS deals with directories
-              names. Windows doesn't add an ending separator so we might add it.
-             */
-            #if defined( WIN32 ) || defined( UNDER_CE )
-            dest_dir += DIR_SEP;
-            #endif
+            dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP;
             msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
             toggleVisible();
             update_Download( p_update, qtu( dest_dir ) );
diff --git a/modules/gui/qt4/dialogs/sout.cpp b/modules/gui/qt4/dialogs/sout.cpp
index 699bd48..2e0f270 100644
--- a/modules/gui/qt4/dialogs/sout.cpp
+++ b/modules/gui/qt4/dialogs/sout.cpp
@@ -216,7 +216,7 @@ void SoutDialog::fileBrowse()
 {
     QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file" ), "",
         qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv)" ) );
-    ui.fileEdit->setText( fileName );
+    ui.fileEdit->setText( toNativeSeparators( fileName ) );
     updateMRL();
 }
 
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 92df106..6715116 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -279,7 +279,7 @@ void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
         {
             p_arg->i_results = 1;
             p_arg->psz_results = (char **)malloc( p_arg->i_results * sizeof( char * ) );
-            p_arg->psz_results[0] = strdup( qtu( file ) );
+            p_arg->psz_results[0] = strdup( qtu( toNativeSepNoSlash( file ) ) );
         }
         else
             p_arg->i_results = 0;
@@ -293,7 +293,7 @@ void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
         p_arg->psz_results = (char **)malloc( p_arg->i_results * sizeof( char * ) );
         i = 0;
         foreach( QString file, files )
-            p_arg->psz_results[i++] = strdup( qtu( file ) );
+            p_arg->psz_results[i++] = strdup( qtu( toNativeSepNoSlash( file ) ) );
     }
 
     /* Callback */
@@ -368,6 +368,7 @@ QStringList DialogsProvider::showSimpleOpen( QString help,
     }
     ADD_FILTER_ALL( fileTypes );
     fileTypes.replace(QString(";*"), QString(" *"));
+
     return QFileDialog::getOpenFileNames( NULL,
         help.isNull() ? qfu(I_OP_SEL_FILES ) : help,
         path.isNull() ? qfu( p_intf->p_sys->psz_filepath ) : path,
@@ -385,7 +386,7 @@ void DialogsProvider::addFromSimple( bool pl, bool go)
     int i = 0;
     foreach( QString file, files )
     {
-        const char * psz_utf8 = qtu( file );
+        const char * psz_utf8 = qtu( toNativeSeparators( file ) );
         playlist_Add( THEPL, psz_utf8, NULL,
                       go ? ( PLAYLIST_APPEND | ( i ? 0 : PLAYLIST_GO ) |
                                                ( i ? PLAYLIST_PREPARSE : 0 ) )
@@ -419,11 +420,13 @@ void DialogsProvider::simpleMLAppendDialog()
  **/
 static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
 {
-    QString dir = QFileDialog::getExistingDirectory( 0, qtr("Open Directory") );
-    if (!dir.isEmpty()) {
+    QString dir = QFileDialog::getExistingDirectory( NULL, qtr("Open Directory") );
+
+    if (!dir.isEmpty() )
+    {
         input_item_t *p_input = input_item_NewExt( THEPL,
-                                        qtu( "directory://" + dir ), NULL,
-                                        0, NULL, -1 );
+                              qtu( "directory://" + toNativeSeparators(dir) ),
+                              NULL, 0, NULL, -1 );
 
         /* FIXME: playlist_AddInput() can fail */
         playlist_AddInput( THEPL, p_input,
@@ -459,7 +462,7 @@ void DialogsProvider::openAPlaylist()
                                         EXT_FILTER_PLAYLIST );
     foreach( QString file, files )
     {
-        playlist_Import( THEPL, qtu(file) );
+        playlist_Import( THEPL, qtu( toNativeSeparators( file ) ) );
     }
 }
 
@@ -499,8 +502,8 @@ void DialogsProvider::saveAPlaylist()
                     file.append( ".m3u" );
             }
 
-            playlist_Export( THEPL, qtu( file ), THEPL->p_local_category,
-                             psz_module);
+            playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
+                        THEPL->p_local_category, psz_module);
         }
     }
     delete qfd;
@@ -633,7 +636,8 @@ void DialogsProvider::loadSubtitlesFile()
     QString qsFile;
     foreach( qsFile, qsl )
     {
-        if( !input_AddSubtitles( p_input, qtu( qsFile ), true ) )
+        if( !input_AddSubtitles( p_input, qtu( toNativeSeparators( qsFile ) ),
+                    true ) )
             msg_Warn( p_intf, "unable to load subtitles from '%s'",
                       qtu( qsFile ) );
     }
diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index 6b8c113..2a0e004 100644
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -132,6 +132,15 @@ static inline QString toNativeSeparators( QString s )
     return s;
 }
 
+static inline QString removeTrailingSlash( QString s )
+{
+    if( ( s.length() > 1 ) && ( s[s.length()-1] == QLatin1Char( '/' ) ) )
+        s.remove( s.length() - 1, 1 );
+    return s;
+}
+
+#define toNativeSepNoSlash( a ) toNativeSeparators( removeTrailingSlash( a ) )
+
 static const int DialogEvent_Type = QEvent::User + DialogEventType + 1;
 //static const int PLUndockEvent_Type = QEvent::User + DialogEventType + 2;
 //static const int PLDockEvent_Type = QEvent::User + DialogEventType + 3;




More information about the vlc-devel mailing list