]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs_provider.cpp
vlc_epg: add parental rating from ts streams.
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
index 7e339b4e2fec129e12b0e3f04446e275f385d2c5..2a15d5b33a8b584099cc48ef583d439b2bd798bf 100644 (file)
@@ -475,26 +475,27 @@ void DialogsProvider::simpleMLAppendDialog()
  **/
 void DialogsProvider::openUrlDialog()
 {
-    OpenUrlDialog *oud = new OpenUrlDialog( p_intf );
-    if( oud->exec() == QDialog::Accepted )
+    OpenUrlDialog oud( p_intf );
+    if( oud.exec() != QDialog::Accepted )
+        return;
+
+    QString url = oud.url();
+    if( url.isEmpty() )
+        return;
+
+    if( !url.contains( qfu( "://" ) ) )
     {
-        QString url = oud->url();
-        if( !url.isEmpty() )
-        {
-            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 );
-            }
-        }
+        char *uri = vlc_path2uri( qtu( url ), NULL );
+        if( uri == NULL )
+            return;
+        url = qfu(uri);
+        free( uri );
     }
-    delete oud;
+    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 );
 }
 
 /* Directory */
@@ -521,7 +522,7 @@ static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
         dir.remove( "BDMV" );
     }
 
-    char *uri = make_URI( qtu( toNativeSeparators( dir ) ), scheme );
+    char *uri = vlc_path2uri( qtu( toNativeSeparators( dir ) ), scheme );
     if( unlikely(uri == NULL) )
         return;
 
@@ -595,20 +596,48 @@ void DialogsProvider::saveAPlaylist()
 
     QString selected;
     QString file = QFileDialog::getSaveFileName( NULL,
-                                  qtr( "Save playlist as..." ),
-                                  p_intf->p_sys->filepath, filters.join( ";;" ),
-                                  &selected );
+                                                 qtr( "Save playlist as..." ),
+                                                 p_intf->p_sys->filepath, filters.join( ";;" ),
+                                                 &selected );
+    const char *psz_selected_module = NULL;
+    const char *psz_last_playlist_ext = NULL;
+
     if( file.isEmpty() )
         return;
 
+    /* First test if the file extension is set, and different to selected filter */
     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 ( file.endsWith( QString( "." ) + 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 );
+            psz_selected_module = types[i].module;
+            psz_last_playlist_ext = types[i].filter_patterns;
             break;
         }
+    }
+
+    /* otherwise apply the selected extension */
+    if ( !psz_last_playlist_ext )
+    {
+        for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++)
+        {
+            if ( selected.startsWith( qfu( vlc_gettext( types[i].filter_name ) ) ) )
+            {
+                psz_selected_module = types[i].module;
+                psz_last_playlist_ext = types[i].filter_patterns;
+                /* Fix file extension */
+                file = file.append( QString( "." ) + qfu( psz_last_playlist_ext ) );
+                break;
+            }
+        }
+    }
+
+    if ( psz_selected_module )
+    {
+        playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
+                         THEPL->p_playing, psz_selected_module );
+        getSettings()->setValue( "last-playlist-ext", psz_last_playlist_ext );
+    }
 }
 
 /****************************************************************************