]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs_provider.cpp
Qt: Fix opening of folders under Win32
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
index b58188fdfa97ea1bfdc3ed99b3f0fbf11d3583cf..5198bdd4c6b9837a143d65f3c16885cd6c5348b3 100644 (file)
 #include "dialogs/toolbar.hpp"
 #include "dialogs/plugins.hpp"
 #include "dialogs/external.hpp"
-#include "dialogs/errors.hpp"
 #include "dialogs/epg.hpp"
+#include "dialogs/errors.hpp"
 
 #include <QEvent>
 #include <QApplication>
 #include <QSignalMapper>
 #include <QFileDialog>
 
+#define I_OP_DIR_WINTITLE I_DIR_OR_FOLDER( N_("Open Directory"), \
+                                           N_("Open Folder") )
 
 DialogsProvider* DialogsProvider::instance = NULL;
 
@@ -94,10 +96,16 @@ DialogsProvider::~DialogsProvider()
 #ifdef UPDATE_CHECK
     UpdateDialog::killInstance();
 #endif
+    PluginDialog::killInstance();
 
     delete menusMapper;
     delete menusUpdateMapper;
     delete SDMapper;
+
+    QVLCMenu::PopupMenu( p_intf, false );
+    QVLCMenu::AudioPopupMenu( p_intf, false );
+    QVLCMenu::VideoPopupMenu( p_intf, false );
+    QVLCMenu::MiscPopupMenu( p_intf, false );
 }
 
 void DialogsProvider::quit()
@@ -146,11 +154,11 @@ void DialogsProvider::customEvent( QEvent *event )
         case INTF_DIALOG_POPUPMENU:
            QVLCMenu::PopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_AUDIOPOPUPMENU:
-           QVLCMenu::AudioPopupMenu( p_intf ); break;
+           QVLCMenu::AudioPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_VIDEOPOPUPMENU:
-           QVLCMenu::VideoPopupMenu( p_intf ); break;
+           QVLCMenu::VideoPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_MISCPOPUPMENU:
-           QVLCMenu::MiscPopupMenu( p_intf ); break;
+           QVLCMenu::MiscPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_WIZARD:
         case INTF_DIALOG_STREAMWIZARD:
             openAndStreamingDialogs(); break;
@@ -428,7 +436,7 @@ void DialogsProvider::addFromSimple( bool pl, bool go)
     files.sort();
     foreach( const QString &file, files )
     {
-        char* psz_uri = make_URI( qtu( toNativeSeparators(file) ) );
+        char* psz_uri = make_URI( qtu( toNativeSeparators(file) ), NULL );
         playlist_Add( THEPL, psz_uri, NULL,
                       go ? ( PLAYLIST_APPEND | ( i ? PLAYLIST_PREPARSE : PLAYLIST_GO ) )
                          : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
@@ -462,7 +470,7 @@ void DialogsProvider::simpleMLAppendDialog()
  **/
 void DialogsProvider::openUrlDialog()
 {
-    OpenUrlDialog *oud = OpenUrlDialog::getInstance( p_intf );
+    OpenUrlDialog *oud = new OpenUrlDialog( p_intf );
     if( oud->exec() == QDialog::Accepted )
     {
         QString url = oud->url();
@@ -476,6 +484,7 @@ void DialogsProvider::openUrlDialog()
             RecentsMRL::getInstance( p_intf )->addRecent( url );
         }
     }
+    delete oud;
 }
 
 /* Directory */
@@ -486,24 +495,33 @@ void DialogsProvider::openUrlDialog()
  **/
 static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
 {
-    QString dir = QFileDialog::getExistingDirectory( NULL, qtr("Open Directory"), p_intf->p_sys->filepath );
+    QString dir = QFileDialog::getExistingDirectory( NULL, qtr( I_OP_DIR_WINTITLE ), p_intf->p_sys->filepath );
 
-    if (!dir.isEmpty() )
-    {
-        QString mrl = (dir.endsWith( "VIDEO_TS", Qt::CaseInsensitive ) ?
-                       "dvd://" : "directory://")
-                    + toNativeSeparators( dir );
-        input_item_t *p_input = input_item_New( THEPL, qtu( mrl ), NULL );
+    if( dir.isEmpty() )
+        return;
 
-        /* FIXME: playlist_AddInput() can fail */
-        playlist_AddInput( THEPL, p_input,
-                       go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
+    const char *scheme = "directory";
+    if( dir.endsWith( "/VIDEO_TS", Qt::CaseInsensitive ) )
+        scheme = "dvd";
+
+    char *uri = make_URI( qtu( toNativeSeparators( dir ) ), scheme );
+    if( unlikely(uri == NULL) )
+        return;
+
+    RecentsMRL::getInstance( p_intf )->addRecent( qfu(uri) );
+
+    input_item_t *p_input = input_item_New( THEPL, uri, NULL );
+    free( uri );
+    if( unlikely( p_input == NULL ) )
+        return;
+
+    /* FIXME: playlist_AddInput() can fail */
+    playlist_AddInput( THEPL, p_input,
+                      go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
                        PLAYLIST_END, pl, pl_Unlocked );
-        RecentsMRL::getInstance( p_intf )->addRecent( mrl );
-        if( !go )
-            input_Read( THEPL, p_input );
-        vlc_gc_decref( p_input );
-    }
+    if( !go )
+        input_Read( THEPL, p_input );
+    vlc_gc_decref( p_input );
 }
 
 void DialogsProvider::PLOpenDir()
@@ -710,7 +728,7 @@ void DialogsProvider::SDMenuAction( const QString& data )
  **/
 void DialogsProvider::playMRL( const QString &mrl )
 {
-    char* psz_uri = make_URI( qtu(mrl) );
+    char* psz_uri = make_URI( qtu(mrl), NULL );
     playlist_Add( THEPL, psz_uri, NULL,
            PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
     free( psz_uri );