Commit f75370e5 authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Wizard: project loading

parent 4cf403b7
/*****************************************************************************
* OpenPage.cpp: Wizard project openning page
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Ludovic Fauvet <etix@l0cal.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QDebug>
#include "OpenPage.h"
#include "ProjectManager.h"
#include "ProjectWizard.h"
OpenPage::OpenPage( QWidget *parent ) :
QWizardPage(parent)
{
ui.setupUi( this );
setTitle( tr( "Project wizard" ) );
setSubTitle( tr( "Ready to load this project" ) );
setFinalPage( true );
}
void OpenPage::changeEvent( QEvent *e )
{
QWizardPage::changeEvent( e );
switch ( e->type() ) {
case QEvent::LanguageChange:
ui.retranslateUi( this );
break;
default:
break;
}
}
bool OpenPage::validatePage()
{
ProjectWizard* pw = qobject_cast<ProjectWizard*>( wizard() );
if ( pw )
{
ProjectManager* pm = ProjectManager::getInstance();
pm->loadProject( pw->projectFileName() );
}
return true;
}
/*****************************************************************************
* OpenPage.h: Wizard project openning page
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Ludovic Fauvet <etix@l0cal.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef OPENPAGE_H
#define OPENPAGE_H
#include "ui_OpenPage.h"
class OpenPage : public QWizardPage
{
Q_OBJECT
public:
OpenPage( QWidget *parent = 0 );
protected:
void changeEvent( QEvent *e );
virtual bool validatePage();
private:
Ui::OpenPage ui;
};
#endif // OPENPAGE_H
......@@ -32,6 +32,7 @@
#include "SettingsManager.h"
#include "PageFactory.h"
#include "WelcomePage.h"
#include "OpenPage.h"
ProjectWizard::ProjectWizard( QWidget* parent )
: QWizard( parent )
......@@ -59,11 +60,13 @@ ProjectWizard::ProjectWizard( QWidget* parent )
QWizardPage* generalPage = PageFactory::generateWizardPage<ProjectPreferences>( "General Settings", this );
QWizardPage* videoPage = PageFactory::generateWizardPage<VideoProjectPreferences>( "Video Settings", this );
QWizardPage* audioPage = PageFactory::generateWizardPage<AudioProjectPreferences>( "Audio Settings", this );
QWizardPage* openPage = new OpenPage( this );
setPage( Page_Welcome, welcomePage );
setPage( Page_General, generalPage );
setPage( Page_Video, videoPage );
setPage( Page_Audio, audioPage );
setPage( Page_Open, openPage );
// Set the start page
setStartId( Page_Welcome );
......@@ -91,9 +94,11 @@ void ProjectWizard::showHelp()
void ProjectWizard::accept()
{
SettingsManager::getInstance()->commit();
if ( currentId() == Page_Audio )
{
SettingsManager::getInstance()->commit();
}
emit flush();
restart();
QDialog::accept();
return ;
}
......@@ -102,7 +107,16 @@ void ProjectWizard::reject()
{
SettingsManager::getInstance()->flush();
emit flush();
restart();
QDialog::reject();
return ;
}
QString ProjectWizard::projectFileName() const
{
return m_projectFileName;
}
void ProjectWizard::setProjectFile( const QString& fileName )
{
m_projectFileName = fileName;
}
......@@ -26,6 +26,8 @@
#include <QWizard>
class WelcomePage;
class ProjectWizard : public QWizard
{
Q_OBJECT
......@@ -38,14 +40,23 @@ class ProjectWizard : public QWizard
ProjectWizard( QWidget* parent = 0 );
~ProjectWizard();
void accept();
void reject();
QString projectFileName() const;
protected slots:
virtual void accept();
virtual void reject();
private slots:
void showHelp();
void showHelp();
private:
void setProjectFile( const QString& fileName );
QString m_projectFileName;
signals:
void flush();
void flush();
friend class WelcomePage;
};
#endif
......@@ -25,6 +25,7 @@
#include <QVBoxLayout>
#include <QMessageBox>
#include <QFileInfo>
#include <QDebug>
#include "WelcomePage.h"
WelcomePage::WelcomePage( QWidget* parent )
......@@ -64,13 +65,25 @@ int WelcomePage::nextId() const
bool WelcomePage::validatePage()
{
if ( m_ui.openRadioButton->isChecked() &&
m_ui.projectsListWidget->count() == 0 )
if ( m_ui.openRadioButton->isChecked() )
{
QMessageBox::information( this, tr( "Sorry" ),
tr( "You first need to select a project from "
"the list.\nThen click next to continue..." ) );
return false;
if ( m_ui.projectsListWidget->selectedItems().count() == 0 )
{
QMessageBox::information( this, tr( "Sorry" ),
tr( "You first need to select a project from "
"the list.\nThen click next to continue..." ) );
return false;
}
// Pass the project filename to the QWizard
// so the next page can load it.
ProjectWizard* pw = qobject_cast<ProjectWizard*>( wizard() );
if ( pw )
{
QList<QListWidgetItem*> items = m_ui.projectsListWidget->selectedItems();
pw->setProjectFile( items.at( 0 )->data( FilePath ).toString() );
}
return true;
}
return true;
}
......@@ -103,6 +116,7 @@ void WelcomePage::loadProject()
if ( projectPath.isEmpty() ) return;
// Search if the item is already in the list
QListWidgetItem* item = NULL;
for ( int i = 0; i < m_ui.projectsListWidget->count(); ++i )
{
......@@ -112,10 +126,11 @@ void WelcomePage::loadProject()
item = NULL;
}
// Item not in list, insert it temporarily
if ( !item )
{
QFileInfo fi( projectPath );
QListWidgetItem* item = new QListWidgetItem( fi.fileName() );
item = new QListWidgetItem( fi.fileName() );
item->setData( FilePath, fi.absoluteFilePath() );
m_ui.projectsListWidget->addItem( item );
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenPage</class>
<widget class="QWizardPage" name="OpenPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;table border=&quot;0&quot; style=&quot;-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;&quot;&gt;
&lt;tr&gt;
&lt;td style=&quot;border: none;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;We have now enough informations to load this project.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Press &lt;span style=&quot; font-weight:600;&quot;&gt;finish&lt;/span&gt; to close this wizard and start editing your videos!&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
HEADERS += CustomWizardPage.h \
WelcomePage.h \
PageFactory.h \
ProjectWizard.h
ProjectWizard.h \
OpenPage.h
SOURCES += CustomWizardPage.cpp \
WelcomePage.cpp \
ProjectWizard.cpp
FORMS += ui/WelcomePage.ui
ProjectWizard.cpp \
OpenPage.cpp
FORMS += ui/WelcomePage.ui \
ui/OpenPage.ui
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