Move song export and track export from Song into MainWindow
The code to export a song and the tracks of a song mainly consisted of GUI code. Therefore it was moved completely into MainWindow. Add two new slots and a method that does the actual work to MainWindow. Make both slots delegate to the worker method.
This commit is contained in:
@@ -196,6 +196,8 @@ private:
|
||||
void toggleWindow( QWidget *window, bool forceShow = false );
|
||||
void refocus();
|
||||
|
||||
void exportProject(bool multiExport = false);
|
||||
|
||||
QMdiArea * m_workspace;
|
||||
|
||||
QWidget * m_toolBar;
|
||||
@@ -244,6 +246,8 @@ private slots:
|
||||
void updateViewMenu( void );
|
||||
void updateConfig( QAction * _who );
|
||||
void onToggleMetronome();
|
||||
void onExportProject();
|
||||
void onExportProjectTracks();
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
@@ -310,8 +310,6 @@ public slots:
|
||||
void stop();
|
||||
|
||||
void importProject();
|
||||
void exportProject( bool multiExport = false );
|
||||
void exportProjectTracks();
|
||||
|
||||
void startExport();
|
||||
void stopExport();
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "ControllerConnection.h"
|
||||
#include "embed.h"
|
||||
#include "EnvelopeAndLfoParameters.h"
|
||||
#include "ExportProjectDialog.h"
|
||||
#include "FxMixer.h"
|
||||
#include "FxMixerView.h"
|
||||
#include "GuiApplication.h"
|
||||
@@ -58,7 +57,6 @@
|
||||
#include "TextFloat.h"
|
||||
#include "TimeLineWidget.h"
|
||||
#include "PeakController.h"
|
||||
#include "VersionedSaveDialog.h"
|
||||
|
||||
|
||||
tick_t MidiTime::s_ticksPerTact = DefaultTicksPerTact;
|
||||
@@ -1305,89 +1303,6 @@ void Song::removeAllControllers()
|
||||
|
||||
|
||||
|
||||
void Song::exportProjectTracks()
|
||||
{
|
||||
exportProject( true );
|
||||
}
|
||||
|
||||
void Song::exportProject( bool multiExport )
|
||||
{
|
||||
FileDialog efd( gui->mainWindow() );
|
||||
|
||||
if ( multiExport )
|
||||
{
|
||||
efd.setFileMode( FileDialog::Directory);
|
||||
efd.setWindowTitle( tr( "Select directory for writing exported tracks..." ) );
|
||||
if( !m_fileName.isEmpty() )
|
||||
{
|
||||
efd.setDirectory( QFileInfo( m_fileName ).absolutePath() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
efd.setFileMode( FileDialog::AnyFile );
|
||||
int idx = 0;
|
||||
QStringList types;
|
||||
while( ProjectRenderer::fileEncodeDevices[idx].m_fileFormat != ProjectRenderer::NumFileFormats)
|
||||
{
|
||||
if(ProjectRenderer::fileEncodeDevices[idx].isAvailable()) {
|
||||
types << tr(ProjectRenderer::fileEncodeDevices[idx].m_description);
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
efd.setNameFilters( types );
|
||||
QString baseFilename;
|
||||
if( !m_fileName.isEmpty() )
|
||||
{
|
||||
efd.setDirectory( QFileInfo( m_fileName ).absolutePath() );
|
||||
baseFilename = QFileInfo( m_fileName ).completeBaseName();
|
||||
}
|
||||
else
|
||||
{
|
||||
efd.setDirectory( ConfigManager::inst()->userProjectsDir() );
|
||||
baseFilename = tr( "untitled" );
|
||||
}
|
||||
efd.selectFile( baseFilename + ProjectRenderer::fileEncodeDevices[0].m_extension );
|
||||
efd.setWindowTitle( tr( "Select file for project-export..." ) );
|
||||
}
|
||||
|
||||
QString suffix = "wav";
|
||||
efd.setDefaultSuffix( suffix );
|
||||
efd.setAcceptMode( FileDialog::AcceptSave );
|
||||
|
||||
if( efd.exec() == QDialog::Accepted && !efd.selectedFiles().isEmpty() &&
|
||||
!efd.selectedFiles()[0].isEmpty() )
|
||||
{
|
||||
|
||||
QString exportFileName = efd.selectedFiles()[0];
|
||||
if ( !multiExport )
|
||||
{
|
||||
int stx = efd.selectedNameFilter().indexOf( "(*." );
|
||||
int etx = efd.selectedNameFilter().indexOf( ")" );
|
||||
|
||||
if ( stx > 0 && etx > stx )
|
||||
{
|
||||
// Get first extension from selected dropdown.
|
||||
// i.e. ".wav" from "WAV-File (*.wav), Dummy-File (*.dum)"
|
||||
suffix = efd.selectedNameFilter().mid( stx + 2, etx - stx - 2 ).split( " " )[0].trimmed();
|
||||
exportFileName.remove( "." + suffix, Qt::CaseInsensitive );
|
||||
if ( efd.selectedFiles()[0].endsWith( suffix ) )
|
||||
{
|
||||
if( VersionedSaveDialog::fileExistsQuery( exportFileName + suffix,
|
||||
tr( "Save project" ) ) )
|
||||
{
|
||||
exportFileName += suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExportProjectDialog epd( exportFileName, gui->mainWindow(), multiExport );
|
||||
epd.exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Song::exportProjectMidi(QString const & exportFileName) const
|
||||
{
|
||||
// instantiate midi export plugin
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "ControllerRackView.h"
|
||||
#include "embed.h"
|
||||
#include "Engine.h"
|
||||
#include "ExportProjectDialog.h"
|
||||
#include "FileBrowser.h"
|
||||
#include "FileDialog.h"
|
||||
#include "FxMixerView.h"
|
||||
@@ -55,6 +56,7 @@
|
||||
#include "PluginView.h"
|
||||
#include "ProjectJournal.h"
|
||||
#include "ProjectNotes.h"
|
||||
#include "ProjectRenderer.h"
|
||||
#include "RemotePlugin.h"
|
||||
#include "SetupDialog.h"
|
||||
#include "SideBar.h"
|
||||
@@ -311,13 +313,13 @@ void MainWindow::finalize()
|
||||
SLOT( importProject() ) );
|
||||
project_menu->addAction( embed::getIconPixmap( "project_export" ),
|
||||
tr( "E&xport..." ),
|
||||
Engine::getSong(),
|
||||
SLOT( exportProject() ),
|
||||
this,
|
||||
SLOT( onExportProject() ),
|
||||
Qt::CTRL + Qt::Key_E );
|
||||
project_menu->addAction( embed::getIconPixmap( "project_export" ),
|
||||
tr( "E&xport Tracks..." ),
|
||||
Engine::getSong(),
|
||||
SLOT( exportProjectTracks() ),
|
||||
this,
|
||||
SLOT( onExportProjectTracks() ),
|
||||
Qt::CTRL + Qt::SHIFT + Qt::Key_E );
|
||||
|
||||
project_menu->addAction( embed::getIconPixmap( "midi_file" ),
|
||||
@@ -450,8 +452,8 @@ void MainWindow::finalize()
|
||||
ToolButton * project_export = new ToolButton(
|
||||
embed::getIconPixmap( "project_export" ),
|
||||
tr( "Export current project" ),
|
||||
Engine::getSong(),
|
||||
SLOT( exportProject() ),
|
||||
this,
|
||||
SLOT( onExportProject() ),
|
||||
m_toolBar );
|
||||
|
||||
ToolButton * whatsthis = new ToolButton(
|
||||
@@ -1612,3 +1614,92 @@ void MainWindow::onExportProjectMidi()
|
||||
Engine::getSong()->exportProjectMidi(export_filename);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::exportProject(bool multiExport)
|
||||
{
|
||||
QString const & projectFileName = Engine::getSong()->projectFileName();
|
||||
|
||||
FileDialog efd( gui->mainWindow() );
|
||||
|
||||
if ( multiExport )
|
||||
{
|
||||
efd.setFileMode( FileDialog::Directory);
|
||||
efd.setWindowTitle( tr( "Select directory for writing exported tracks..." ) );
|
||||
if( !projectFileName.isEmpty() )
|
||||
{
|
||||
efd.setDirectory( QFileInfo( projectFileName ).absolutePath() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
efd.setFileMode( FileDialog::AnyFile );
|
||||
int idx = 0;
|
||||
QStringList types;
|
||||
while( ProjectRenderer::fileEncodeDevices[idx].m_fileFormat != ProjectRenderer::NumFileFormats)
|
||||
{
|
||||
if(ProjectRenderer::fileEncodeDevices[idx].isAvailable()) {
|
||||
types << tr(ProjectRenderer::fileEncodeDevices[idx].m_description);
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
efd.setNameFilters( types );
|
||||
QString baseFilename;
|
||||
if( !projectFileName.isEmpty() )
|
||||
{
|
||||
efd.setDirectory( QFileInfo( projectFileName ).absolutePath() );
|
||||
baseFilename = QFileInfo( projectFileName ).completeBaseName();
|
||||
}
|
||||
else
|
||||
{
|
||||
efd.setDirectory( ConfigManager::inst()->userProjectsDir() );
|
||||
baseFilename = tr( "untitled" );
|
||||
}
|
||||
efd.selectFile( baseFilename + ProjectRenderer::fileEncodeDevices[0].m_extension );
|
||||
efd.setWindowTitle( tr( "Select file for project-export..." ) );
|
||||
}
|
||||
|
||||
QString suffix = "wav";
|
||||
efd.setDefaultSuffix( suffix );
|
||||
efd.setAcceptMode( FileDialog::AcceptSave );
|
||||
|
||||
if( efd.exec() == QDialog::Accepted && !efd.selectedFiles().isEmpty() &&
|
||||
!efd.selectedFiles()[0].isEmpty() )
|
||||
{
|
||||
|
||||
QString exportFileName = efd.selectedFiles()[0];
|
||||
if ( !multiExport )
|
||||
{
|
||||
int stx = efd.selectedNameFilter().indexOf( "(*." );
|
||||
int etx = efd.selectedNameFilter().indexOf( ")" );
|
||||
|
||||
if ( stx > 0 && etx > stx )
|
||||
{
|
||||
// Get first extension from selected dropdown.
|
||||
// i.e. ".wav" from "WAV-File (*.wav), Dummy-File (*.dum)"
|
||||
suffix = efd.selectedNameFilter().mid( stx + 2, etx - stx - 2 ).split( " " )[0].trimmed();
|
||||
exportFileName.remove( "." + suffix, Qt::CaseInsensitive );
|
||||
if ( efd.selectedFiles()[0].endsWith( suffix ) )
|
||||
{
|
||||
if( VersionedSaveDialog::fileExistsQuery( exportFileName + suffix,
|
||||
tr( "Save project" ) ) )
|
||||
{
|
||||
exportFileName += suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExportProjectDialog epd( exportFileName, gui->mainWindow(), multiExport );
|
||||
epd.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onExportProject()
|
||||
{
|
||||
this->exportProject();
|
||||
}
|
||||
|
||||
void MainWindow::onExportProjectTracks()
|
||||
{
|
||||
this->exportProject(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user