[vlc-commits] Qt, save the last extension used for saving playlist

Jean-Baptiste Kempf git at videolan.org
Mon Apr 25 22:07:10 CEST 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Apr 25 22:05:48 2011 +0200| [ca0eddecb510148d6c2ba84e57bcad509fa85d34] | committer: Jean-Baptiste Kempf

Qt, save the last extension used for saving playlist

Close #3094
Of course, there is a very more elegant way, but Qt Native Dialog on
Linux don't do it correctly. This is a Qt bug.

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

 modules/gui/qt4/dialogs_provider.cpp |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 1677814..690adf6 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -553,29 +553,32 @@ 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;
 
@@ -584,6 +587,7 @@ void DialogsProvider::saveAPlaylist()
         {
             playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
                              THEPL->p_playing, types[i].module );
+            getSettings()->setValue( "last-playlist-ext", types[i].filter_patterns );
             break;
         }
 }



More information about the vlc-commits mailing list