From 7d78268f8547add7baaf34bc28f61a41c03a90ee Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 25 Jul 2010 00:33:48 +0200 Subject: [PATCH] ExportProjectDialog: guess file format from extension If we choose to export an OGG file in the first dialog, it's really annoying having to select OGG a second time. Therefore guess file format from extension (backport from master). --- src/gui/export_project_dialog.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gui/export_project_dialog.cpp b/src/gui/export_project_dialog.cpp index 3db5b6d98..c3804eaa3 100644 --- a/src/gui/export_project_dialog.cpp +++ b/src/gui/export_project_dialog.cpp @@ -42,12 +42,34 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name, setWindowTitle( tr( "Export project to %1" ).arg( QFileInfo( _file_name ).fileName() ) ); + // get the extension of the chosen file + QStringList parts = _file_name.split( '.' ); + QString fileExt; + if( parts.size() > 0 ) + { + fileExt = "." + parts[parts.size()-1]; + } + + int cbIndex = 0; for( int i = 0; i < ProjectRenderer::NumFileFormats; ++i ) { if( __fileEncodeDevices[i].m_getDevInst != NULL ) { + // get the extension of this format + QString renderExt = __fileEncodeDevices[i].m_extension; + + // add to combo box fileFormatCB->addItem( ProjectRenderer::tr( __fileEncodeDevices[i].m_description ) ); + + // if this is our extension, select it + if( QString::compare( renderExt, fileExt, + Qt::CaseInsensitive ) == 0 ) + { + fileFormatCB->setCurrentIndex( cbIndex ); + } + + cbIndex++; } }