Commit 2037bb71 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: determine saved playlist format from selected filter...

...rather than extension (if any). Fixes: #3016.
Also make the code a bit more generic.
parent 3232ed95
...@@ -525,36 +525,36 @@ void DialogsProvider::openAPlaylist() ...@@ -525,36 +525,36 @@ void DialogsProvider::openAPlaylist()
void DialogsProvider::saveAPlaylist() void DialogsProvider::saveAPlaylist()
{ {
QString file = QFileDialog::getSaveFileName( NULL, static const struct
qtr( "Save playlist as..." ),
p_intf->p_sys->filepath,
qtr( "XSPF playlist (*.xspf);; " ) +
qtr( "M3U playlist (*.m3u);; " ) +
qtr( "HTML playlist (*.html)" ) );
if( !file.isEmpty() )
{ {
static const char psz_xspf[] = "export-xspf", char filter[24];
psz_m3u[] = "export-m3u", char module[12];
psz_html[] = "export-html"; } types[] = {
const char *psz_module; { N_("XSPF playlist (*.xpsf)"), "export-xspf", },
{ N_("M3U playlist (*.m3u)"), "export-m3u", },
if( file.contains( ".xsp" ) ) { N_("HTML playlist (*.html)"), "export-html", },
psz_module = psz_xspf; };
else if( file.contains( ".m3u" ) ) QString filters, selected;
psz_module = psz_m3u;
else if( file.contains(".html" ) ) for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++ )
psz_module = psz_html;
else
{ {
msg_Warn( p_intf, "Impossible to recognise the file type. " if( !filters.isEmpty() )
"Defaulting to XSPF" ); filters += ";;";
psz_module = psz_xspf; filters += qfu( vlc_gettext( types[i].filter ) );
file.append( ".xspf" );
} }
QString file = QFileDialog::getSaveFileName( NULL,
qtr( "Save playlist as..." ),
p_intf->p_sys->filepath, filters, &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 ) ) )
{
playlist_Export( THEPL, qtu( toNativeSeparators( file ) ), playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
THEPL->p_local_category, psz_module); THEPL->p_local_category, types[i].module );
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