[vlmc-devel] Wizard: Quit if closed before a project is loaded/created
Hugo Beauzée-Luyssen
git at videolan.org
Sat Mar 29 01:03:39 CET 2014
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Mar 27 00:17:27 2014 +0200| [8f217282461e8df112bc597b55b718720636f908] | committer: Hugo Beauzée-Luyssen
Wizard: Quit if closed before a project is loaded/created
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=8f217282461e8df112bc597b55b718720636f908
---
src/Gui/MainWindow.cpp | 24 +++++++++++++-----------
src/Gui/MainWindow.h | 8 ++++----
src/Gui/wizard/ProjectWizard.cpp | 17 +++++++++++++----
src/Gui/wizard/ProjectWizard.h | 10 +++++++---
src/Project/ProjectManager.cpp | 6 ++++++
src/Project/ProjectManager.h | 1 +
6 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 51c7478..c3e4802 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -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
diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h
index 20524ae..c070228 100644
--- a/src/Gui/MainWindow.h
+++ b/src/Gui/MainWindow.h
@@ -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;
diff --git a/src/Gui/wizard/ProjectWizard.cpp b/src/Gui/wizard/ProjectWizard.cpp
index 7e46632..ae0d921 100644
--- a/src/Gui/wizard/ProjectWizard.cpp
+++ b/src/Gui/wizard/ProjectWizard.cpp
@@ -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();
}
diff --git a/src/Gui/wizard/ProjectWizard.h b/src/Gui/wizard/ProjectWizard.h
index 718a2fb..eb02b07 100644
--- a/src/Gui/wizard/ProjectWizard.h
+++ b/src/Gui/wizard/ProjectWizard.h
@@ -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
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index 00c48c4..d2ef81b 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -213,6 +213,12 @@ ProjectManager::emergencyBackup()
}
bool
+ProjectManager::hasProjectLoaded() const
+{
+ return m_projectFile != NULL;
+}
+
+bool
ProjectManager::isBackupFile( const QString& projectFile )
{
return projectFile.endsWith( ProjectManager::backupSuffix );
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index 0b75000..c1f70d8 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -51,6 +51,7 @@ public:
virtual void saveAs( const QString &outputFileName );
bool loadEmergencyBackup();
void emergencyBackup();
+ bool hasProjectLoaded() const;
protected:
/**
More information about the Vlmc-devel
mailing list