Commit c85b9123 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

The wizzard now really creates a project.

If a project is currently oppened, it is closed.
parent 8be771a5
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "WelcomePage.h" #include "WelcomePage.h"
#include "OpenPage.h" #include "OpenPage.h"
#include <QtDebug>
ProjectWizard::ProjectWizard( QWidget* parent ) ProjectWizard::ProjectWizard( QWidget* parent )
: QWizard( parent ) : QWizard( parent )
{ {
...@@ -98,6 +100,8 @@ void ProjectWizard::accept() ...@@ -98,6 +100,8 @@ void ProjectWizard::accept()
{ {
SettingsManager::getInstance()->commit(); SettingsManager::getInstance()->commit();
} }
ProjectManager::getInstance()->newProject(
SettingsManager::getInstance()->getValue( "project", "ProjectName" )->get().toString() );
emit flush(); emit flush();
QDialog::accept(); QDialog::accept();
return ; return ;
......
...@@ -93,6 +93,9 @@ void ProjectManager::loadProject( const QString& fileName ) ...@@ -93,6 +93,9 @@ void ProjectManager::loadProject( const QString& fileName )
if ( fileName.length() == 0 ) if ( fileName.length() == 0 )
return; return;
if ( closeProject() == false )
return ;
// Append the item to the recents list // Append the item to the recents list
m_recentsProjects.removeAll( fileName ); m_recentsProjects.removeAll( fileName );
m_recentsProjects.prepend( fileName ); m_recentsProjects.prepend( fileName );
...@@ -102,8 +105,6 @@ void ProjectManager::loadProject( const QString& fileName ) ...@@ -102,8 +105,6 @@ void ProjectManager::loadProject( const QString& fileName )
QSettings s; QSettings s;
s.setValue( "RecentsProjects", m_recentsProjects ); s.setValue( "RecentsProjects", m_recentsProjects );
closeProject();
m_projectFile = new QFile( fileName ); m_projectFile = new QFile( fileName );
m_domDocument = new QDomDocument; m_domDocument = new QDomDocument;
...@@ -176,22 +177,25 @@ void ProjectManager::saveProject( bool saveAs /*= true*/ ) ...@@ -176,22 +177,25 @@ void ProjectManager::saveProject( bool saveAs /*= true*/ )
emit projectSaved(); emit projectSaved();
} }
//void ProjectManager::newProject( const QString &projectName ) void ProjectManager::newProject( const QString &projectName )
//{ {
// if ( closeProject() if ( closeProject() == false )
// m_fi return ;
//} m_projectName = projectName;
emit projectUpdated( m_projectName, true );
}
void ProjectManager::closeProject() bool ProjectManager::closeProject()
{ {
if ( askForSaveIfModified() == false ) if ( askForSaveIfModified() == false )
return ; return false;
if ( m_projectFile != NULL ) if ( m_projectFile != NULL )
{ {
delete m_projectFile; delete m_projectFile;
m_projectFile = NULL; m_projectFile = NULL;
} }
emit projectClosed(); emit projectClosed();
return true;
} }
bool ProjectManager::askForSaveIfModified() bool ProjectManager::askForSaveIfModified()
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
void saveProject( bool saveAs = true ); void saveProject( bool saveAs = true );
bool needSave() const; bool needSave() const;
QStringList recentsProjects() const; QStringList recentsProjects() const;
void closeProject(); bool closeProject();
bool askForSaveIfModified(); bool askForSaveIfModified();
private: private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment