Commit ca0eddec authored by Jean-Baptiste Kempf's avatar 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.
parent e5ef811f
...@@ -553,29 +553,32 @@ void DialogsProvider::saveAPlaylist() ...@@ -553,29 +553,32 @@ void DialogsProvider::saveAPlaylist()
static const struct static const struct
{ {
char filter_name[14]; char filter_name[14];
char filter_patterns[7]; char filter_patterns[5];
char module[12]; char module[12];
} types[] = { } types[] = {
{ N_("XSPF playlist"), "*.xspf", "export-xspf", }, { N_("XSPF playlist"), "xspf", "export-xspf", },
{ N_("M3U8 playlist"), "*.m3u8", "export-m3u8", }, { N_("M3U playlist"), "m3u", "export-m3u", },
{ N_("M3U playlist"), "*.m3u", "export-m3u", }, { N_("M3U8 playlist"), "m3u8", "export-m3u8", },
{ N_("HTML playlist"), "*.html", "export-html", }, { 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++ ) for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++ )
{ {
if( !filters.isEmpty() ) QString tmp = qfu( vlc_gettext( types[i].filter_name ) ) + " (*." + types[i].filter_patterns + ")";
filters += ";;"; if( ext == qfu( types[i].filter_patterns ) )
filters += qfu( vlc_gettext( types[i].filter_name ) ); filters.insert( 0, tmp );
filters += " ("; else
filters += qfu( types[i].filter_patterns ); filters.append( tmp );
filters += ")";
} }
QString selected;
QString file = QFileDialog::getSaveFileName( NULL, QString file = QFileDialog::getSaveFileName( NULL,
qtr( "Save playlist as..." ), qtr( "Save playlist as..." ),
p_intf->p_sys->filepath, filters, &selected ); p_intf->p_sys->filepath, filters.join( ";;" ),
&selected );
if( file.isEmpty() ) if( file.isEmpty() )
return; return;
...@@ -584,6 +587,7 @@ void DialogsProvider::saveAPlaylist() ...@@ -584,6 +587,7 @@ void DialogsProvider::saveAPlaylist()
{ {
playlist_Export( THEPL, qtu( toNativeSeparators( file ) ), playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
THEPL->p_playing, types[i].module ); THEPL->p_playing, types[i].module );
getSettings()->setValue( "last-playlist-ext", types[i].filter_patterns );
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment