void ProjectManager::set_current_project(Project* project) { PENTER; QString oldprojectname = ""; if (m_currentProject) { ied().reject_current_hold_actions(); // printf("exit in progress"); QString oncloseaction = config().get_property("Project", "onclose", "save").toString(); if (oncloseaction == "save") { m_currentProject->save(); } else if (oncloseaction == "ask") { QMessageBox::StandardButton button = QMessageBox::question(0, tr("Save Project"), tr("Should Project '%1' be safed before closing it?").arg(m_currentProject->get_title()), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (button == QMessageBox::Yes) { m_currentProject->save(); } } oldprojectname = m_currentProject->get_title(); m_currentProject->disconnect_from_audio_device(); // this serves as a 'project closed' signal, emiting // a zero pointer as project makes the GUI to delete it's // project and releated GUI objects emit projectLoaded(0); delete m_currentProject; } m_currentProject = project; if (m_currentProject) { config().set_property("Project", "current", m_currentProject->get_title()); emit projectLoaded(m_currentProject); } else if (!m_exitInProgress) { // free the audiodevice, but only if we don't want to quit. audiodevice().set_parameters(AudioDeviceSetup()); } if ( ! oldprojectname.isEmpty() ) { cleanup_backupfiles_for_project(oldprojectname); } }
void Project::newProject( const QString &projectName, const QString& projectPath ) { m_projectName = projectName; //Current project file has already been delete/nulled by closeProject() m_projectFile = new QFile( projectPath + "/project.vlmc" ); save(); emit projectLoaded( projectName, m_projectFile->fileName() ); }
// load given song void song::loadProject( const QString & _file_name ) { QDomNode node; m_loadingProject = true; clearProject(); engine::projectJournal()->setJournalling( false ); m_fileName = _file_name; m_oldFileName = _file_name; DataFile dataFile( m_fileName ); // if file could not be opened, head-node is null and we create // new project if( dataFile.head().isNull() ) { createNewProject(); return; } DataFile::LocaleHelper localeHelper( DataFile::LocaleHelper::ModeLoad ); engine::mixer()->lock(); // get the header information from the DOM m_tempoModel.loadSettings( dataFile.head(), "bpm" ); m_timeSigModel.loadSettings( dataFile.head(), "timesig" ); m_masterVolumeModel.loadSettings( dataFile.head(), "mastervol" ); m_masterPitchModel.loadSettings( dataFile.head(), "masterpitch" ); if( m_playPos[Mode_PlaySong].m_timeLine ) { // reset loop-point-state m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 ); } if( !dataFile.content().firstChildElement( "track" ).isNull() ) { m_globalAutomationTrack->restoreState( dataFile.content(). firstChildElement( "track" ) ); } //Backward compatibility for LMMS <= 0.4.15 PeakController::initGetControllerBySetting(); // Load mixer first to be able to set the correct range for FX channels node = dataFile.content().firstChildElement( engine::fxMixer()->nodeName() ); if( !node.isNull() ) { engine::fxMixer()->restoreState( node.toElement() ); if( engine::hasGUI() ) { // refresh FxMixerView engine::fxMixerView()->refreshDisplay(); } } node = dataFile.content().firstChild(); while( !node.isNull() ) { if( node.isElement() ) { if( node.nodeName() == "trackcontainer" ) { ( (JournallingObject *)( this ) )->restoreState( node.toElement() ); } else if( node.nodeName() == "controllers" ) { restoreControllerStates( node.toElement() ); } else if( engine::hasGUI() ) { if( node.nodeName() == engine::getControllerRackView()->nodeName() ) { engine::getControllerRackView()->restoreState( node.toElement() ); } else if( node.nodeName() == engine::pianoRoll()->nodeName() ) { engine::pianoRoll()->restoreState( node.toElement() ); } else if( node.nodeName() == engine::automationEditor()->nodeName() ) { engine::automationEditor()->restoreState( node.toElement() ); } else if( node.nodeName() == engine::getProjectNotes()->nodeName() ) { engine::getProjectNotes()->SerializingObject::restoreState( node.toElement() ); } else if( node.nodeName() == m_playPos[Mode_PlaySong].m_timeLine->nodeName() ) { m_playPos[Mode_PlaySong].m_timeLine->restoreState( node.toElement() ); } } } node = node.nextSibling(); } // quirk for fixing projects with broken positions of TCOs inside // BB-tracks engine::getBBTrackContainer()->fixIncorrectPositions(); // Connect controller links to their controllers // now that everything is loaded ControllerConnection::finalizeConnections(); // resolve all IDs so that autoModels are automated AutomationPattern::resolveAllIDs(); engine::mixer()->unlock(); configManager::inst()->addRecentlyOpenedProject( _file_name ); engine::projectJournal()->setJournalling( true ); emit projectLoaded(); m_loadingProject = false; m_modified = false; if( engine::mainWindow() ) { engine::mainWindow()->resetWindowTitle(); } }
// load given song void Song::loadProject( const QString & fileName ) { QDomNode node; m_loadingProject = true; Engine::projectJournal()->setJournalling( false ); m_oldFileName = m_fileName; m_fileName = fileName; DataFile dataFile( m_fileName ); // if file could not be opened, head-node is null and we create // new project if( dataFile.head().isNull() ) { if( m_loadOnLaunch ) { createNewProject(); } m_fileName = m_oldFileName; return; } m_oldFileName = m_fileName; clearProject(); clearErrors(); DataFile::LocaleHelper localeHelper( DataFile::LocaleHelper::ModeLoad ); Engine::mixer()->requestChangeInModel(); // get the header information from the DOM m_tempoModel.loadSettings( dataFile.head(), "bpm" ); m_timeSigModel.loadSettings( dataFile.head(), "timesig" ); m_masterVolumeModel.loadSettings( dataFile.head(), "mastervol" ); m_masterPitchModel.loadSettings( dataFile.head(), "masterpitch" ); if( m_playPos[Mode_PlaySong].m_timeLine ) { // reset loop-point-state m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 ); } if( !dataFile.content().firstChildElement( "track" ).isNull() ) { m_globalAutomationTrack->restoreState( dataFile.content(). firstChildElement( "track" ) ); } //Backward compatibility for LMMS <= 0.4.15 PeakController::initGetControllerBySetting(); // Load mixer first to be able to set the correct range for FX channels node = dataFile.content().firstChildElement( Engine::fxMixer()->nodeName() ); if( !node.isNull() ) { Engine::fxMixer()->restoreState( node.toElement() ); if( gui ) { // refresh FxMixerView gui->fxMixerView()->refreshDisplay(); } } node = dataFile.content().firstChild(); QDomNodeList tclist=dataFile.content().elementsByTagName("trackcontainer"); m_nLoadingTrack=0; for( int i=0,n=tclist.count(); i<n; ++i ) { QDomNode nd=tclist.at(i).firstChild(); while(!nd.isNull()) { if( nd.isElement() && nd.nodeName() == "track" ) { ++m_nLoadingTrack; if( nd.toElement().attribute("type").toInt() == Track::BBTrack ) { n += nd.toElement().elementsByTagName("bbtrack").at(0) .toElement().firstChildElement().childNodes().count(); } nd=nd.nextSibling(); } } } while( !node.isNull() ) { if( node.isElement() ) { if( node.nodeName() == "trackcontainer" ) { ( (JournallingObject *)( this ) )->restoreState( node.toElement() ); } else if( node.nodeName() == "controllers" ) { restoreControllerStates( node.toElement() ); } else if( gui ) { if( node.nodeName() == gui->getControllerRackView()->nodeName() ) { gui->getControllerRackView()->restoreState( node.toElement() ); } else if( node.nodeName() == gui->pianoRoll()->nodeName() ) { gui->pianoRoll()->restoreState( node.toElement() ); } else if( node.nodeName() == gui->automationEditor()->m_editor->nodeName() ) { gui->automationEditor()->m_editor->restoreState( node.toElement() ); } else if( node.nodeName() == gui->getProjectNotes()->nodeName() ) { gui->getProjectNotes()->SerializingObject::restoreState( node.toElement() ); } else if( node.nodeName() == m_playPos[Mode_PlaySong].m_timeLine->nodeName() ) { m_playPos[Mode_PlaySong].m_timeLine->restoreState( node.toElement() ); } } } node = node.nextSibling(); } // quirk for fixing projects with broken positions of TCOs inside // BB-tracks Engine::getBBTrackContainer()->fixIncorrectPositions(); // Connect controller links to their controllers // now that everything is loaded ControllerConnection::finalizeConnections(); // resolve all IDs so that autoModels are automated AutomationPattern::resolveAllIDs(); Engine::mixer()->doneChangeInModel(); ConfigManager::inst()->addRecentlyOpenedProject( fileName ); Engine::projectJournal()->setJournalling( true ); emit projectLoaded(); if ( hasErrors()) { if ( gui ) { QMessageBox::warning( NULL, tr("LMMS Error report"), errorSummary(), QMessageBox::Ok ); } else { QTextStream(stderr) << Engine::getSong()->errorSummary() << endl; } } m_loadingProject = false; m_modified = false; m_loadOnLaunch = false; if( gui && gui->mainWindow() ) { gui->mainWindow()->resetWindowTitle(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , userSettings(QSettings::UserScope, "Jason Gedge", "StereoReconstruction") , trayIcon(nullptr) , recentFiles(userSettings.value("recentFileList").toStringList()) { ui->setupUi(this); // // Recent Files // QSignalMapper *recentFilesMapper = new QSignalMapper(this); connect(recentFilesMapper, SIGNAL(mapped(int)), SLOT(openRecentFile(int))); for(int index = 0; index < NUM_RECENT_FILES; ++index) { recentFileActions[index] = ui->menuOpen_Recent->addAction( QString("%1: <No File>").arg(index + 1), recentFilesMapper, SLOT(map()) ); recentFileActions[index]->setVisible(false); recentFilesMapper->setMapping(recentFileActions[index], index); } { // Move separator + "clear recent files" to end QAction *act = ui->menuOpen_Recent->actions().first(); ui->menuOpen_Recent->removeAction(act); ui->menuOpen_Recent->addAction(act); act = ui->menuOpen_Recent->actions().first(); ui->menuOpen_Recent->removeAction(act); ui->menuOpen_Recent->addAction(act); } // // // trayIcon = new QSystemTrayIcon(this); #ifndef HAS_IMAGE_CAPTURE ui->menuBar->removeAction(ui->menuCapture->menuAction()); #endif #ifndef HAS_HDR ui->menuBar->removeAction(ui->menuHDR->menuAction()); #endif // // // projectExplorerDock = new QDockWidget(tr("Project Explorer"), this); projectExplorerDock->setObjectName(QString::fromUtf8("projectExplorerDock")); projectExplorerDock->setMinimumWidth(200); projectExplorerDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::LeftDockWidgetArea, projectExplorerDock); projectExplorerDock->hide(); projectExplorer = new ProjectExplorer(this); projectExplorerDock->setWidget(projectExplorer); connect(projectExplorer, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showProjectMenu(QPoint))); // // // imageSetTable = new ImageSetTable(this); imageSetTable->setEnabled(false); cameraInfoWidget = new CameraInfoWidget(this); cameraInfoWidget->setEnabled(false); inspectorDock = new QDockWidget(tr("Inspector"), this); inspectorDock->setObjectName(QString::fromUtf8("inspectorDock")); inspectorDock->setMinimumWidth(350); inspectorDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea, inspectorDock); inspectorDock->hide(); inspector = new QStackedWidget(inspectorDock); inspector->addWidget(new QWidget(this)); inspector->addWidget(cameraInfoWidget); inspector->addWidget(imageSetTable); inspectorDock->setWidget(inspector); // // // taskList = new QWidget(this); taskList->setAutoFillBackground(true); taskList->setBackgroundRole(QPalette::Light); taskList->setObjectName(QString::fromUtf8("taskList")); taskList->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); taskList->setMinimumHeight(50); // XXX necessary? taskListLayout = new QVBoxLayout(taskList); taskListLayout->setMargin(0); taskListLayout->addStretch(1); taskListDock = new QDockWidget(tr("Task List"), this); taskListDock->setObjectName(QString::fromUtf8("taskListDock")); taskListDock->setWidget(taskList); taskListDock->setAllowedAreas(Qt::AllDockWidgetAreas); addDockWidget(Qt::BottomDockWidgetArea, taskListDock); taskListDock->hide(); // // TODO move these to the ui files // connect(projectExplorer, SIGNAL(cameraSelected(CameraPtr)), SLOT(cameraSelected(CameraPtr)) ); connect(projectExplorer, SIGNAL(imageSetSelected(ImageSetPtr)), SLOT(imageSetSelected(ImageSetPtr)) ); connect(projectExplorerDock, SIGNAL(visibilityChanged(bool)), SLOT(on_actionShowHide_Project_Explorer_triggered(bool)) ); connect(inspectorDock, SIGNAL(visibilityChanged(bool)), SLOT(on_actionShowHide_Inspector_triggered(bool)) ); projectExplorer->connect(this, SIGNAL(projectLoaded(ProjectPtr)), SLOT(setProject(ProjectPtr)) ); cameraInfoWidget->connect(this, SIGNAL(projectLoaded(ProjectPtr)), SLOT(setProject(ProjectPtr)) ); cameraInfoWidget->connect(projectExplorer, SIGNAL(cameraSelected(CameraPtr)), SLOT(setCamera(CameraPtr)) ); imageSetTable->connect(this, SIGNAL(projectLoaded(ProjectPtr)), SLOT(setProject(ProjectPtr)) ); imageSetTable->connect(projectExplorer, SIGNAL(imageSetSelected(ImageSetPtr)), SLOT(setImageSet(ImageSetPtr)) ); ui->stereoWidget->connect(this, SIGNAL(projectLoaded(ProjectPtr)), SLOT(setProject(ProjectPtr)) ); // // Set up initial window state // restoreGeometry(userSettings.value("mainWindowGeometry").toByteArray()); restoreState(userSettings.value("mainWindowState").toByteArray()); updateRecentFiles(); ui->actionView_Nothing->trigger(); ui->actionNew->trigger(); }