]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs_provider.cpp
Qt4: Set the current rate properly
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
index ed0fa36d2c9fda309af3be3ae6d3ed50ffcecdb1..f34cb03d1df8695fd36d365236c69cdb26f8c20b 100644 (file)
@@ -91,22 +91,22 @@ DialogsProvider::~DialogsProvider()
     PlaylistDialog::killInstance();
     MediaInfoDialog::killInstance();
     MessagesDialog::killInstance();
-    ExtendedDialog::killInstance();
     BookmarksDialog::killInstance();
     HelpDialog::killInstance();
 #ifdef UPDATE_CHECK
     UpdateDialog::killInstance();
 #endif
     PluginDialog::killInstance();
+    EpgDialog::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 );
+    VLCMenuBar::PopupMenu( p_intf, false );
+    VLCMenuBar::AudioPopupMenu( p_intf, false );
+    VLCMenuBar::VideoPopupMenu( p_intf, false );
+    VLCMenuBar::MiscPopupMenu( p_intf, false );
 }
 
 void DialogsProvider::quit()
@@ -153,13 +153,13 @@ void DialogsProvider::customEvent( QEvent *event )
            vlmDialog(); break;
 #endif
         case INTF_DIALOG_POPUPMENU:
-           QVLCMenu::PopupMenu( p_intf, (de->i_arg != 0) ); break;
+           VLCMenuBar::PopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_AUDIOPOPUPMENU:
-           QVLCMenu::AudioPopupMenu( p_intf, (de->i_arg != 0) ); break;
+           VLCMenuBar::AudioPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_VIDEOPOPUPMENU:
-           QVLCMenu::VideoPopupMenu( p_intf, (de->i_arg != 0) ); break;
+           VLCMenuBar::VideoPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_MISCPOPUPMENU:
-           QVLCMenu::MiscPopupMenu( p_intf, (de->i_arg != 0) ); break;
+           VLCMenuBar::MiscPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_WIZARD:
         case INTF_DIALOG_STREAMWIZARD:
             openAndStreamingDialogs(); break;
@@ -191,20 +191,24 @@ void DialogsProvider::prefsDialog()
 
 void DialogsProvider::extendedDialog()
 {
-    if( !ExtendedDialog::getInstance( p_intf )->isVisible() || /* Hidden */
-        ExtendedDialog::getInstance( p_intf )->currentTab() != 0 )  /* wrong tab */
-        ExtendedDialog::getInstance( p_intf )->showTab( 0 );
+    ExtendedDialog *extDialog = ExtendedDialog::getInstance(p_intf );
+
+    if( !extDialog->isVisible() || /* Hidden */
+        extDialog->currentTab() != 0 )  /* wrong tab */
+        extDialog->showTab( 0 );
     else
-        ExtendedDialog::getInstance( p_intf )->hide();
+        extDialog->hide();
 }
 
 void DialogsProvider::synchroDialog()
 {
-    if( !ExtendedDialog::getInstance( p_intf )->isVisible() || /* Hidden */
-        ExtendedDialog::getInstance( p_intf )->currentTab() != 2 )  /* wrong tab */
-        ExtendedDialog::getInstance( p_intf )->showTab( 2 );
+    ExtendedDialog *extDialog = ExtendedDialog::getInstance(p_intf );
+
+    if( !extDialog->isVisible() || /* Hidden */
+        extDialog->currentTab() != 2 )  /* wrong tab */
+        extDialog->showTab( 2 );
     else
-        ExtendedDialog::getInstance( p_intf )->hide();
+        extDialog->hide();
 }
 
 void DialogsProvider::messagesDialog()
@@ -398,21 +402,21 @@ QStringList DialogsProvider::showSimpleOpen( const QString& help,
 {
     QString fileTypes = "";
     if( filters & EXT_FILTER_MEDIA ) {
-        ADD_FILTER_MEDIA( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_MEDIA );
     }
     if( filters & EXT_FILTER_VIDEO ) {
-        ADD_FILTER_VIDEO( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_VIDEO );
     }
     if( filters & EXT_FILTER_AUDIO ) {
-        ADD_FILTER_AUDIO( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_AUDIO );
     }
     if( filters & EXT_FILTER_PLAYLIST ) {
-        ADD_FILTER_PLAYLIST( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_PLAYLIST );
     }
     if( filters & EXT_FILTER_SUBTITLE ) {
-        ADD_FILTER_SUBTITLE( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_SUBTITLE );
     }
-    ADD_FILTER_ALL( fileTypes );
+    ADD_EXT_FILTER( fileTypes, EXTENSIONS_ALL );
     fileTypes.replace( ";*", " *");
 
     QStringList files = QFileDialog::getOpenFileNames( NULL,
@@ -474,12 +478,17 @@ void DialogsProvider::openUrlDialog()
         QString url = oud->url();
         if( !url.isEmpty() )
         {
-            playlist_Add( THEPL, qtu( url ),
-                          NULL, !oud->shouldEnqueue() ?
-                                  ( PLAYLIST_APPEND | PLAYLIST_GO )
-                                : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
-                          PLAYLIST_END, true, false );
-            RecentsMRL::getInstance( p_intf )->addRecent( url );
+            char *uri = make_URI( qtu( url ), NULL );
+            if( likely( uri != NULL ) )
+            {
+                playlist_Add( THEPL, uri,
+                              NULL, !oud->shouldEnqueue() ?
+                                      ( PLAYLIST_APPEND | PLAYLIST_GO )
+                                    : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
+                              PLAYLIST_END, true, false );
+                RecentsMRL::getInstance( p_intf )->addRecent( url );
+                free( uri );
+            }
         }
     }
     delete oud;
@@ -498,9 +507,16 @@ static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
     if( dir.isEmpty() )
         return;
 
+    p_intf->p_sys->filepath = dir;
+
     const char *scheme = "directory";
     if( dir.endsWith( "/VIDEO_TS", Qt::CaseInsensitive ) )
         scheme = "dvd";
+    else if( dir.endsWith( "/BDMV", Qt::CaseInsensitive ) )
+    {
+        scheme = "bluray";
+        dir.remove( "BDMV" );
+    }
 
     char *uri = make_URI( qtu( toNativeSeparators( dir ) ), scheme );
     if( unlikely(uri == NULL) )
@@ -508,17 +524,15 @@ static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
 
     RecentsMRL::getInstance( p_intf )->addRecent( qfu(uri) );
 
-    input_item_t *p_input = input_item_New( THEPL, uri, NULL );
+    input_item_t *p_input = input_item_New( 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,
+                       go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
                        PLAYLIST_END, pl, pl_Unlocked );
-    if( !go )
-        input_Read( THEPL, p_input );
     vlc_gc_decref( p_input );
 }
 
@@ -555,37 +569,41 @@ void DialogsProvider::saveAPlaylist()
     static const struct
     {
         char filter_name[14];
-        char filter_patterns[7];
+        char filter_patterns[5];
         char module[12];
     } types[] = {
-        { N_("XSPF playlist"), "*.xspf", "export-xspf", },
-        { N_("M3U8 playlist"), "*.m3u8", "export-m3u8", },
-        { N_("M3U playlist"), "*.m3u", "export-m3u", },
-        { N_("HTML playlist"), "*.html", "export-html", },
+        { N_("XSPF playlist"), "xspf", "export-xspf", },
+        { N_("M3U playlist"),  "m3u",  "export-m3u", },
+        { N_("M3U8 playlist"), "m3u8", "export-m3u8", },
+        { N_("HTML playlist"), "html", "export-html", },
     };
-    QString filters, selected;
+
+    QStringList filters;
+    QString ext = getSettings()->value( "last-playlist-ext" ).toString();
 
     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++ )
     {
-        if( !filters.isEmpty() )
-            filters += ";;";
-        filters += qfu( vlc_gettext( types[i].filter_name ) );
-        filters += " (";
-        filters += qfu( types[i].filter_patterns );
-        filters += ")";
+        QString tmp = qfu( vlc_gettext( types[i].filter_name ) ) + " (*." + types[i].filter_patterns + ")";
+        if( ext == qfu( types[i].filter_patterns ) )
+            filters.insert( 0, tmp );
+        else
+            filters.append( tmp );
     }
 
+    QString selected;
     QString file = QFileDialog::getSaveFileName( NULL,
                                   qtr( "Save playlist as..." ),
-                                  p_intf->p_sys->filepath, filters, &selected );
+                                  p_intf->p_sys->filepath, filters.join( ";;" ),
+                                  &selected );
     if( file.isEmpty() )
         return;
 
     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++)
-        if( selected == qfu( vlc_gettext( types[i].filter_name ) ) + " (" + qfu( types[i].filter_patterns ) + ")" )
+        if( selected == qfu( vlc_gettext( types[i].filter_name ) ) + " (*." + qfu( types[i].filter_patterns ) + ")" )
         {
             playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
                              THEPL->p_playing, types[i].module );
+            getSettings()->setValue( "last-playlist-ext", types[i].filter_patterns );
             break;
         }
 }
@@ -605,6 +623,7 @@ void DialogsProvider::streamingDialog( QWidget *parent,
     if( !b_transcode_only )
     {
         SoutDialog *s = new SoutDialog( parent, p_intf, mrl );
+        s->setAttribute( Qt::WA_QuitOnClose, false ); // See #4883
         if( s->exec() == QDialog::Accepted )
         {
             soutoption = s->getMrl();
@@ -617,6 +636,7 @@ void DialogsProvider::streamingDialog( QWidget *parent,
     } else {
     /* Convert */
         ConvertDialog *s = new ConvertDialog( parent, p_intf, mrl );
+        s->setAttribute( Qt::WA_QuitOnClose, false ); // See #4883
         if( s->exec() == QDialog::Accepted )
         {
             soutoption = s->getMrl();
@@ -635,10 +655,10 @@ void DialogsProvider::streamingDialog( QWidget *parent,
 
         /* Create Input */
         input_item_t *p_input;
-        p_input = input_item_New( p_intf, qtu( mrl ), _("Streaming") );
+        p_input = input_item_New( qtu( mrl ), _("Streaming") );
 
         /* Add normal Options */
-        for( int j = 0; j < options.size(); j++ )
+        for( int j = 0; j < options.count(); j++ )
         {
             QString qs = colon_unescape( options[j] );
             if( !qs.isEmpty() )
@@ -680,15 +700,22 @@ void DialogsProvider::loadSubtitlesFile()
     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';
+    char *path2 = NULL;
+    if( path )
+    {
+        path2 = make_path( path );
+        free( path );
+        if( path2 )
+        {
+            char *sep = strrchr( path2, DIR_SEP_CHAR );
+            if( sep ) *sep = '\0';
+        }
+    }
 
     QStringList qsl = showSimpleOpen( qtr( "Open subtitles..." ),
                                       EXT_FILTER_SUBTITLE,
-                                      qfu( path ) );
-    free( path );
+                                      qfu( path2 ) );
+    free( path2 );
     foreach( const QString &qsFile, qsl )
     {
         if( input_AddSubtitle( p_input, qtu( toNativeSeparators( qsFile ) ),
@@ -705,7 +732,7 @@ void DialogsProvider::loadSubtitlesFile()
 
 void DialogsProvider::menuAction( QObject *data )
 {
-    QVLCMenu::DoAction( data );
+    VLCMenuBar::DoAction( data );
 }
 
 void DialogsProvider::menuUpdateAction( QObject *data )
@@ -717,12 +744,10 @@ void DialogsProvider::menuUpdateAction( QObject *data )
 
 void DialogsProvider::SDMenuAction( const QString& data )
 {
-    char *psz_sd = strdup( qtu( data ) );
-    if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) )
-        playlist_ServicesDiscoveryAdd( THEPL, psz_sd );
+    if( !playlist_IsServicesDiscoveryLoaded( THEPL, qtu( data ) ) )
+        playlist_ServicesDiscoveryAdd( THEPL, qtu( data ) );
     else
-        playlist_ServicesDiscoveryRemove( THEPL, psz_sd );
-    free( psz_sd );
+        playlist_ServicesDiscoveryRemove( THEPL, qtu( data ) );
 }
 
 /**
@@ -730,7 +755,12 @@ void DialogsProvider::SDMenuAction( const QString& data )
  **/
 void DialogsProvider::playMRL( const QString &mrl )
 {
-    playlist_Add( THEPL, qtu(mrl), NULL,
+    char *uri = make_URI( qtu( mrl ), NULL );
+    if( unlikely( uri == NULL ) )
+        return;
+
+    playlist_Add( THEPL, uri, NULL,
            PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
     RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+    free( uri );
 }