From 73fdfb4ef1f779ba5c8bc7eff63dcab81bfe45d8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 16 Jul 2009 05:19:26 -0700 Subject: [PATCH] exportPorjectDialog - default output file format exportProjectDialog - select the output file format based on what the user has already chosen in the export dialog. Prevents the user from having to choose twice. (also fixed whitespace and added modelines where applicable) --- TODO | 1 - include/project_renderer.h | 6 ++++-- src/gui/export_project_dialog.cpp | 25 ++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 70ed927da..08ac880ea 100644 --- a/TODO +++ b/TODO @@ -54,7 +54,6 @@ Andrew Kelley's todo: * when you press down or up while browsing the resource browser, it should play the sample -* select the output file format based on what you selected in file->save as * load asdlol.mmpz. if you render it without playing it, or if you play it the first time, you hear unwanted artifacts. diff --git a/include/project_renderer.h b/include/project_renderer.h index bddb5a534..ca7aac2a4 100644 --- a/include/project_renderer.h +++ b/include/project_renderer.h @@ -37,11 +37,11 @@ public: { WaveFile, OggFile, - Mp3File, + Mp3File, NumFileFormats } ; - static const char * EFF_ext[]; + static const char * EFF_ext[]; enum Depths { @@ -120,3 +120,5 @@ struct fileEncodeDevice extern fileEncodeDevice __fileEncodeDevices[]; #endif + +/* vim: set tw=0 noexpandtab: */ diff --git a/src/gui/export_project_dialog.cpp b/src/gui/export_project_dialog.cpp index 1a4e929e9..45af89dc3 100644 --- a/src/gui/export_project_dialog.cpp +++ b/src/gui/export_project_dialog.cpp @@ -46,12 +46,32 @@ 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 file_ext = ""; + if( parts.size() > 0 ) + file_ext = 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 render_ext = projectRenderer::EFF_ext[i]; + + // add to combo box fileFormatCB->addItem( projectRenderer::tr( __fileEncodeDevices[i].m_description ) ); + + // if this is our extension, select it + if( QString::compare(render_ext, file_ext, + Qt::CaseInsensitive ) == 0 ) + { + fileFormatCB->setCurrentIndex(cbIndex); + } + + cbIndex++; } } @@ -145,7 +165,7 @@ void exportProjectDialog::startBtnClicked( void ) m_renderer = new projectRenderer( qs, os, ft, m_fileName ); if( m_renderer->isReady() ) { - updateTitleBar( 0 ); + updateTitleBar( 0 ); connect( m_renderer, SIGNAL( progressChanged( int ) ), progressBar, SLOT( setValue( int ) ) ); connect( m_renderer, SIGNAL( progressChanged( int ) ), @@ -178,3 +198,6 @@ void exportProjectDialog::updateTitleBar( int _prog ) #endif + + +/* vim: set tw=0 noexpandtab: */