Respect build options in export dialogs (#3714)
* Respect build options in ExportProjectDialog * Use QItem user data instead of hard ordering to identify export format in ExportProjectDialog * For compatibility with QVariant, ExportFileFormats is now explicitly an int. * Don't break out of format identifier loop prematurely in Song export.
This commit is contained in:
@@ -35,7 +35,7 @@ class ProjectRenderer : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ExportFileFormats
|
||||
enum ExportFileFormats: int
|
||||
{
|
||||
WaveFile,
|
||||
OggFile,
|
||||
|
||||
@@ -1328,10 +1328,11 @@ void Song::exportProject( bool multiExport )
|
||||
efd.setFileMode( FileDialog::AnyFile );
|
||||
int idx = 0;
|
||||
QStringList types;
|
||||
while( ProjectRenderer::fileEncodeDevices[idx].m_fileFormat != ProjectRenderer::NumFileFormats &&
|
||||
ProjectRenderer::fileEncodeDevices[idx].isAvailable())
|
||||
while( ProjectRenderer::fileEncodeDevices[idx].m_fileFormat != ProjectRenderer::NumFileFormats)
|
||||
{
|
||||
types << tr( ProjectRenderer::fileEncodeDevices[idx].m_description );
|
||||
if(ProjectRenderer::fileEncodeDevices[idx].isAvailable()) {
|
||||
types << tr(ProjectRenderer::fileEncodeDevices[idx].m_description);
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
efd.setNameFilters( types );
|
||||
|
||||
@@ -65,7 +65,9 @@ ExportProjectDialog::ExportProjectDialog( const QString & _file_name,
|
||||
|
||||
// add to combo box
|
||||
fileFormatCB->addItem( ProjectRenderer::tr(
|
||||
ProjectRenderer::fileEncodeDevices[i].m_description ) );
|
||||
ProjectRenderer::fileEncodeDevices[i].m_description ),
|
||||
QVariant(ProjectRenderer::fileEncodeDevices[i].m_fileFormat) // format tag; later used for identification
|
||||
);
|
||||
|
||||
// if this is our extension, select it
|
||||
if( QString::compare( renderExt, fileExt,
|
||||
@@ -187,29 +189,16 @@ void ExportProjectDialog::startExport()
|
||||
}
|
||||
|
||||
|
||||
ProjectRenderer::ExportFileFormats convertIndexToExportFileFormat(int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
return ProjectRenderer::WaveFile;
|
||||
case 1:
|
||||
return ProjectRenderer::OggFile;
|
||||
case 2:
|
||||
return ProjectRenderer::MP3File;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return ProjectRenderer::NumFileFormats;
|
||||
}
|
||||
|
||||
|
||||
void ExportProjectDialog::onFileFormatChanged(int index)
|
||||
{
|
||||
ProjectRenderer::ExportFileFormats exportFormat =
|
||||
convertIndexToExportFileFormat(index);
|
||||
// Extract the format tag from the currently selected item,
|
||||
// and adjust the UI properly.
|
||||
QVariant format_tag = fileFormatCB->itemData(index);
|
||||
bool successful_conversion = false;
|
||||
auto exportFormat = static_cast<ProjectRenderer::ExportFileFormats>(
|
||||
format_tag.toInt(&successful_conversion)
|
||||
);
|
||||
Q_ASSERT(successful_conversion);
|
||||
|
||||
bool stereoModeVisible = exportFormat == ProjectRenderer::MP3File;
|
||||
|
||||
@@ -236,28 +225,31 @@ void ExportProjectDialog::startBtnClicked()
|
||||
{
|
||||
m_ft = ProjectRenderer::NumFileFormats;
|
||||
|
||||
//Get file format from current menu selection.
|
||||
bool successful_conversion = false;
|
||||
QVariant tag = fileFormatCB->itemData(fileFormatCB->currentIndex());
|
||||
m_ft = static_cast<ProjectRenderer::ExportFileFormats>(tag.toInt(&successful_conversion));
|
||||
|
||||
if( !successful_conversion )
|
||||
{
|
||||
QMessageBox::information( this, tr( "Error" ),
|
||||
tr( "Error while determining file-encoder device. "
|
||||
"Please try to choose a different output "
|
||||
"format." ) );
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
// Find proper file extension.
|
||||
for( int i = 0; i < ProjectRenderer::NumFileFormats; ++i )
|
||||
{
|
||||
if( fileFormatCB->currentText() ==
|
||||
ProjectRenderer::tr(
|
||||
ProjectRenderer::fileEncodeDevices[i].m_description ) )
|
||||
if (m_ft == ProjectRenderer::fileEncodeDevices[i].m_fileFormat)
|
||||
{
|
||||
m_ft = ProjectRenderer::fileEncodeDevices[i].m_fileFormat;
|
||||
m_fileExtension = QString( QLatin1String( ProjectRenderer::fileEncodeDevices[i].m_extension ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( m_ft == ProjectRenderer::NumFileFormats )
|
||||
{
|
||||
QMessageBox::information( this, tr( "Error" ),
|
||||
tr( "Error while determining file-encoder device. "
|
||||
"Please try to choose a different output "
|
||||
"format." ) );
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
startButton->setEnabled( false );
|
||||
progressBar->setEnabled( true );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user