Commit 8f217282 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Wizard: Quit if closed before a project is loaded/created

parent c1d3c252
......@@ -72,8 +72,11 @@
#include "LanguageHelper.h"
#include "Commands/KeyboardShortcutHelper.h"
MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent ) :
QMainWindow( parent ), m_backend( backend ), m_fileRenderer( NULL )
MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
: QMainWindow( parent )
, m_backend( backend )
, m_fileRenderer( NULL )
, m_wizard( NULL )
{
m_ui.setupUi( this );
......@@ -134,12 +137,6 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent ) :
connect( Project::getInstance()->library(), SIGNAL( clipRemoved( const QUuid& ) ),
clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
//FIXME: Lazy init this
// Wizard
m_pWizard = new ProjectWizard( this );
m_pWizard->setModal( true );
#ifdef WITH_CRASHHANDLER
if ( restoreSession() == true )
return ;
......@@ -161,7 +158,12 @@ MainWindow::~MainWindow()
void
MainWindow::showWizard()
{
m_pWizard->show();
if ( m_wizard == NULL )
{
m_wizard = new ProjectWizard( GUIProjectManager::getInstance(), this );
m_wizard->setModal( true );
}
m_wizard->show();
}
void
......@@ -717,8 +719,8 @@ MainWindow::on_actionShare_On_Internet_triggered()
void
MainWindow::on_actionNew_Project_triggered()
{
m_pWizard->restart();
m_pWizard->show();
m_wizard->restart();
m_wizard->show();
}
void
......
......@@ -131,10 +131,10 @@ private:
PreviewWidget* m_projectPreview;
WorkflowFileRenderer* m_fileRenderer;
WorkflowRenderer *m_renderer;
SettingsDialog* m_globalPreferences;
SettingsDialog* m_DefaultProjectPreferences;
SettingsDialog* m_projectPreferences;
ProjectWizard* m_pWizard;
SettingsDialog* m_globalPreferences;
SettingsDialog* m_DefaultProjectPreferences;
SettingsDialog* m_projectPreferences;
ProjectWizard* m_wizard;
ImportController* m_importController;
MediaLibrary *m_mediaLibrary;
EffectsListView *m_effectsList;
......
......@@ -24,16 +24,19 @@
#include <QString>
#include <QMessageBox>
#include <QWizardPage>
#include "project/GuiProjectManager.h"
#include "Project/ProjectManager.h"
#include "ProjectWizard.h"
#include "Settings/Settings.h"
#include "WelcomePage.h"
#include "OpenPage.h"
#include "GeneralPage.h"
#include "VideoPage.h"
#include "Tools/VlmcDebug.h"
ProjectWizard::ProjectWizard( QWidget* parent )
ProjectWizard::ProjectWizard( ProjectManager* projectManager, QWidget* parent /*= NULL*/ )
: QWizard( parent )
, m_projectManager( projectManager )
{
// Create Wizard
......@@ -99,7 +102,11 @@ ProjectWizard::accept()
{
Settings* preferences = Core::getInstance()->settings();
Settings* projectPreferences = Project::getInstance()->settings();
GUIProjectManager::getInstance()->newProject( field( "projectName" ).toString(), field( "projectPath" ).toString() );
// m_projectManager->newProject( field( "projectName" ).toString(), field( "projectPath" ).toString() );
//FIXME: This doesn't ask the user if she wants to save the current project
vlmcCritical() << "This is broken";
m_projectManager->closeProject();
m_projectManager->saveAs( field( "projectPath" ).toString() );
preferences->setValue( "vlmc/DefaultProjectLocation", field( "workspace" ) );
......@@ -117,5 +124,7 @@ ProjectWizard::accept()
void
ProjectWizard::reject()
{
QDialog::reject();
if ( m_projectManager->hasProjectLoaded() )
return QWizard::reject();
qApp->quit();
}
......@@ -24,9 +24,10 @@
#ifndef PROJECTWIZARD_H
#define PROJECTWIZARD_H
#include <QWizard>
class ProjectManager;
class WelcomePage;
class WelcomePage;
#include <QWizard>
class ProjectWizard : public QWizard
{
......@@ -37,7 +38,7 @@ class ProjectWizard : public QWizard
Page_Open,
Page_General, Page_Video };
ProjectWizard( QWidget* parent = 0 );
ProjectWizard( ProjectManager *projectManager, QWidget* parent = NULL );
~ProjectWizard();
protected slots:
......@@ -46,6 +47,9 @@ class ProjectWizard : public QWizard
private slots:
void showHelp();
private:
ProjectManager* m_projectManager;
};
#endif
......@@ -212,6 +212,12 @@ ProjectManager::emergencyBackup()
Core::getInstance()->settings()->setValue( SETTINGS_BACKUP, name );
}
bool
ProjectManager::hasProjectLoaded() const
{
return m_projectFile != NULL;
}
bool
ProjectManager::isBackupFile( const QString& projectFile )
{
......
......@@ -51,6 +51,7 @@ public:
virtual void saveAs( const QString &outputFileName );
bool loadEmergencyBackup();
void emergencyBackup();
bool hasProjectLoaded() const;
protected:
/**
......
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