2 * export_project_dialog.cpp - implementation of dialog for exporting project
4 * Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
25 #include <QtCore/QFileInfo>
26 #include <QtGui/QMessageBox>
28 #include "export_project_dialog.h"
30 #include "MainWindow.h"
31 #include "ProjectRenderer.h"
34 exportProjectDialog::exportProjectDialog( const QString
& _file_name
,
37 Ui::ExportProjectDialog(),
38 m_fileName( _file_name
),
42 setWindowTitle( tr( "Export project to %1" ).arg(
43 QFileInfo( _file_name
).fileName() ) );
45 // get the extension of the chosen file
46 QStringList parts
= _file_name
.split( '.' );
48 if( parts
.size() > 0 )
50 fileExt
= "." + parts
[parts
.size()-1];
54 for( int i
= 0; i
< ProjectRenderer::NumFileFormats
; ++i
)
56 if( __fileEncodeDevices
[i
].m_getDevInst
!= NULL
)
58 // get the extension of this format
59 QString renderExt
= __fileEncodeDevices
[i
].m_extension
;
62 fileFormatCB
->addItem( ProjectRenderer::tr(
63 __fileEncodeDevices
[i
].m_description
) );
65 // if this is our extension, select it
66 if( QString::compare( renderExt
, fileExt
,
67 Qt::CaseInsensitive
) == 0 )
69 fileFormatCB
->setCurrentIndex( cbIndex
);
76 connect( startButton
, SIGNAL( clicked() ),
77 this, SLOT( startBtnClicked() ) );
84 exportProjectDialog::~exportProjectDialog()
92 void exportProjectDialog::reject()
94 if( m_renderer
== NULL
)
100 m_renderer
->abortProcessing();
107 void exportProjectDialog::closeEvent( QCloseEvent
* _ce
)
109 if( m_renderer
!= NULL
&& m_renderer
->isRunning() )
111 m_renderer
->abortProcessing();
113 QDialog::closeEvent( _ce
);
119 void exportProjectDialog::startBtnClicked()
121 ProjectRenderer::ExportFileFormats ft
= ProjectRenderer::NumFileFormats
;
123 for( int i
= 0; i
< ProjectRenderer::NumFileFormats
; ++i
)
125 if( fileFormatCB
->currentText() ==
127 __fileEncodeDevices
[i
].m_description
) )
129 ft
= __fileEncodeDevices
[i
].m_fileFormat
;
134 if( ft
== ProjectRenderer::NumFileFormats
)
136 QMessageBox::information( this, tr( "Error" ),
137 tr( "Error while determining file-encoder device. "
138 "Please try to choose a different output "
144 startButton
->setEnabled( false );
145 progressBar
->setEnabled( true );
149 mixer::qualitySettings qs
= mixer::qualitySettings(
150 static_cast<mixer::qualitySettings::Interpolation
>(
151 interpolationCB
->currentIndex() ),
152 static_cast<mixer::qualitySettings::Oversampling
>(
153 oversamplingCB
->currentIndex() ),
154 sampleExactControllersCB
->isChecked(),
155 aliasFreeOscillatorsCB
->isChecked() );
157 ProjectRenderer::OutputSettings os
= ProjectRenderer::OutputSettings(
158 samplerateCB
->currentText().section( " ", 0, 0 ).toUInt(),
160 bitrateCB
->currentText().section( " ", 0, 0 ).toUInt(),
161 static_cast<ProjectRenderer::Depths
>(
162 depthCB
->currentIndex() ) );
164 m_renderer
= new ProjectRenderer( qs
, os
, ft
, m_fileName
);
165 if( m_renderer
->isReady() )
167 connect( m_renderer
, SIGNAL( progressChanged( int ) ),
168 progressBar
, SLOT( setValue( int ) ) );
169 connect( m_renderer
, SIGNAL( progressChanged( int ) ),
170 this, SLOT( updateTitleBar( int ) ) );
171 connect( m_renderer
, SIGNAL( finished() ),
172 this, SLOT( accept() ) );
173 connect( m_renderer
, SIGNAL( finished() ),
174 engine::mainWindow(), SLOT( resetWindowTitle() ) );
176 m_renderer
->startProcessing();
187 void exportProjectDialog::updateTitleBar( int _prog
)
189 engine::mainWindow()->setWindowTitle(
190 tr( "Rendering: %1%" ).arg( _prog
) );
195 #include "moc_export_project_dialog.cxx"
198 /* vim: set tw=0 noexpandtab: */