Move import functionality from Song to MainWindow
Move the functionality of the method Song::importProject into the MainWindow as it mainly consists of GUI related actions. Add a new method Song::setLoadOnLauch to ensure that the boolean Song::m_loadOnLaunch is still set at the end of the import.
This commit is contained in:
@@ -248,6 +248,7 @@ private slots:
|
||||
void onToggleMetronome();
|
||||
void onExportProject();
|
||||
void onExportProjectTracks();
|
||||
void onImportProject();
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
@@ -300,6 +300,8 @@ public:
|
||||
|
||||
void exportProjectMidi(QString const & exportFileName) const;
|
||||
|
||||
inline void setLoadOnLauch(bool value) { m_loadOnLaunch = value; }
|
||||
|
||||
public slots:
|
||||
void playSong();
|
||||
void record();
|
||||
@@ -309,8 +311,6 @@ public slots:
|
||||
void togglePause();
|
||||
void stop();
|
||||
|
||||
void importProject();
|
||||
|
||||
void startExport();
|
||||
void stopExport();
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "BBEditor.h"
|
||||
#include "BBTrack.h"
|
||||
#include "BBTrackContainer.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "ControllerRackView.h"
|
||||
#include "ControllerConnection.h"
|
||||
#include "embed.h"
|
||||
@@ -45,10 +44,8 @@
|
||||
#include "FxMixer.h"
|
||||
#include "FxMixerView.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "ImportFilter.h"
|
||||
#include "ExportFilter.h"
|
||||
#include "MainWindow.h"
|
||||
#include "FileDialog.h"
|
||||
#include "Pattern.h"
|
||||
#include "PianoRoll.h"
|
||||
#include "ProjectJournal.h"
|
||||
@@ -1239,28 +1236,6 @@ bool Song::guiSaveProjectAs( const QString & _file_name )
|
||||
|
||||
|
||||
|
||||
void Song::importProject()
|
||||
{
|
||||
FileDialog ofd( NULL, tr( "Import file" ),
|
||||
ConfigManager::inst()->userProjectsDir(),
|
||||
tr("MIDI sequences") +
|
||||
" (*.mid *.midi *.rmi);;" +
|
||||
tr("Hydrogen projects") +
|
||||
" (*.h2song);;" +
|
||||
tr("All file types") +
|
||||
" (*.*)");
|
||||
|
||||
ofd.setFileMode( FileDialog::ExistingFiles );
|
||||
if( ofd.exec () == QDialog::Accepted && !ofd.selectedFiles().isEmpty() )
|
||||
{
|
||||
ImportFilter::import( ofd.selectedFiles()[0], this );
|
||||
}
|
||||
m_loadOnLaunch = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Song::saveControllerStates( QDomDocument & doc, QDomElement & element )
|
||||
{
|
||||
// save settings of controllers
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "FileDialog.h"
|
||||
#include "FxMixerView.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "ImportFilter.h"
|
||||
#include "PianoRoll.h"
|
||||
#include "PluginBrowser.h"
|
||||
#include "PluginFactory.h"
|
||||
@@ -309,8 +310,8 @@ void MainWindow::finalize()
|
||||
project_menu->addSeparator();
|
||||
project_menu->addAction( embed::getIconPixmap( "project_import" ),
|
||||
tr( "Import..." ),
|
||||
Engine::getSong(),
|
||||
SLOT( importProject() ) );
|
||||
this,
|
||||
SLOT( onImportProject() ) );
|
||||
project_menu->addAction( embed::getIconPixmap( "project_export" ),
|
||||
tr( "E&xport..." ),
|
||||
this,
|
||||
@@ -1703,3 +1704,28 @@ void MainWindow::onExportProjectTracks()
|
||||
{
|
||||
this->exportProject(true);
|
||||
}
|
||||
|
||||
void MainWindow::onImportProject()
|
||||
{
|
||||
Song * song = Engine::getSong();
|
||||
|
||||
if (song)
|
||||
{
|
||||
FileDialog ofd( nullptr, tr( "Import file" ),
|
||||
ConfigManager::inst()->userProjectsDir(),
|
||||
tr("MIDI sequences") +
|
||||
" (*.mid *.midi *.rmi);;" +
|
||||
tr("Hydrogen projects") +
|
||||
" (*.h2song);;" +
|
||||
tr("All file types") +
|
||||
" (*.*)");
|
||||
|
||||
ofd.setFileMode( FileDialog::ExistingFiles );
|
||||
if( ofd.exec () == QDialog::Accepted && !ofd.selectedFiles().isEmpty() )
|
||||
{
|
||||
ImportFilter::import( ofd.selectedFiles()[0], song );
|
||||
}
|
||||
|
||||
song->setLoadOnLauch(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user