Commit a0fdf749 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.
(cherry picked from commit 2037bb71)
parent 621be0e2
...@@ -527,36 +527,36 @@ void DialogsProvider::openAPlaylist() ...@@ -527,36 +527,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