[vlc-devel] commit: Qt: use the native dialog for Save Playlist (Jean-Baptiste Kempf )
git version control
git at videolan.org
Sun Jun 21 18:03:43 CEST 2009
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Jun 21 18:02:42 2009 +0200| [fe5ba7a24296d5ad14852385ab91eb24b04737dc] | committer: Jean-Baptiste Kempf
Qt: use the native dialog for Save Playlist
This is better for translations, and look'n feel.
This defaults the name to .xspf, if not a valid extension is provided.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fe5ba7a24296d5ad14852385ab91eb24b04737dc
---
modules/gui/qt4/dialogs_provider.cpp | 75 ++++++++++++---------------------
1 files changed, 27 insertions(+), 48 deletions(-)
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 2f27d3c..9db54c8 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -515,58 +515,37 @@ void DialogsProvider::openAPlaylist()
void DialogsProvider::saveAPlaylist()
{
- QFileDialog *qfd = new QFileDialog( NULL,
- qtr( "Save playlist as..." ),
- p_intf->p_sys->filepath,
- qtr( "XSPF playlist (*.xspf);; " ) +
- qtr( "M3U playlist (*.m3u);; " ) +
- qtr( "HTML playlist (*.html)" ) );
- qfd->setFileMode( QFileDialog::AnyFile );
- qfd->setAcceptMode( QFileDialog::AcceptSave );
- qfd->setConfirmOverwrite( true );
-
- if( qfd->exec() == QDialog::Accepted )
+ QString file = QFileDialog::getSaveFileName( NULL,
+ qtr( "Save playlist as..." ),
+ p_intf->p_sys->filepath,
+ qtr( "XSPF playlist (*.xspf);; " ) +
+ qtr( "M3U playlist (*.m3u);; " ) +
+ qtr( "HTML playlist (*.html)" ) );
+
+ if( !file.isEmpty() )
{
- if( qfd->selectedFiles().count() > 0 )
+ static const char psz_xspf[] = "export-xspf",
+ psz_m3u[] = "export-m3u",
+ psz_html[] = "export-html";
+ const char *psz_module;
+
+ if( file.contains( ".xsp" ) )
+ psz_module = psz_xspf;
+ else if( file.contains( ".m3u" ) )
+ psz_module = psz_m3u;
+ else if( file.contains(".html" ) )
+ psz_module = psz_html;
+ else
{
- static const char psz_xspf[] = "export-xspf",
- psz_m3u[] = "export-m3u",
- psz_html[] = "export-html";
- const char *psz_module;
-
- QString file = qfd->selectedFiles().first();
- QString filter = qfd->selectedFilter();
-
- if( file.contains( ".xsp" ) || filter.contains( "XSPF" ) )
- {
- psz_module = psz_xspf;
- if( !file.contains( ".xsp" ) )
- file.append( ".xspf" );
- }
- else if( file.contains( ".m3u" ) || filter.contains( "M3U" ) )
- {
- psz_module = psz_m3u;
- if( !file.contains( ".m3u" ) )
- file.append( ".m3u" );
- }
- else if( file.contains(".html" ) || filter.contains( "HTML" ) )
- {
- psz_module = psz_html;
- if( !file.contains( "html" ) )
- file.append( ".html" );
- }
- else
- {
- msg_Err( p_intf, "Impossible to recognise the file type" );
- delete qfd;
- return;
- }
-
- playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
- THEPL->p_local_category, psz_module);
+ msg_Warn( p_intf, "Impossible to recognise the file type. "
+ "Defaulting to XSPF" );
+ psz_module = psz_xspf;
+ file.append( ".xpsf" );
}
+
+ playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
+ THEPL->p_local_category, psz_module);
}
- delete qfd;
}
/****************************************************************************
More information about the vlc-devel
mailing list