Commit b5955f39 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Full remake of the wizard.

Introduce support for:
- Workspace management
- Video and audio presets

Some of the provided options aren't working yet. It's only a matter of
time.
parent 138eb261
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QtDebug> #include <QtDebug>
#include <QVariant> #include <QVariant>
#include <QDir>
#include "VLMCSettingsDefault.h" #include "VLMCSettingsDefault.h"
#include "SettingsManager.h" #include "SettingsManager.h"
...@@ -45,7 +46,10 @@ void VLMCSettingsDefault::loadVLMCDefaults( const QString& part ) ...@@ -45,7 +46,10 @@ void VLMCSettingsDefault::loadVLMCDefaults( const QString& part )
"VLMCOutPutFPS", defaultOutputPFS ); "VLMCOutPutFPS", defaultOutputPFS );
settingsMan->setValue( part, settingsMan->setValue( part,
"VLMCTracksNb", "VLMCTracksNb",
defaultTrackNb ); defaultTrackNb );
settingsMan->setValue( part,
"VLMCWorkspace",
QDir::homePath() );
return ; return ;
} }
......
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
#include "GeneralPage.h"
#include "ProjectWizard.h"
#include "SettingsManager.h"
GeneralPage::GeneralPage( QWidget *parent ) :
QWizardPage( parent )
{
ui.setupUi( this );
setTitle( tr( "New project wizard" ) );
setSubTitle( tr( "Set General options" ) );
// Create palettes
pValid = pInvalid = palette();
pInvalid.setColor( QPalette::Text, QColor( 215, 30, 30 ) );
connect( ui.pushButtonBrowse, SIGNAL( clicked() ),
this, SLOT( openWorkspaceDirectory() ) );
connect( ui.lineEditName, SIGNAL( textChanged(QString) ),
this, SLOT( updateProjectLocation() ) );
connect( ui.lineEditWorkspace, SIGNAL( textChanged(QString) ),
this, SLOT( updateProjectLocation() ) );
registerField( "projectName*", ui.lineEditName );
}
void GeneralPage::changeEvent( QEvent *e )
{
QWizardPage::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
ui.retranslateUi( this );
break;
default:
break;
}
}
int GeneralPage::nextId() const
{
return ProjectWizard::Page_Video;
}
void GeneralPage::initializePage()
{
SettingsManager* sManager = SettingsManager::getInstance();
QString projectName = sManager->getValue( "default", "ProjectName" )->get().toString();
ui.lineEditName->setText( projectName );
QString workspacePath = sManager->getValue( "default", "VLMCWorkspace" )->get().toString();
ui.lineEditWorkspace->setText( workspacePath );
updateProjectLocation();
}
void GeneralPage::cleanupPage()
{
}
bool GeneralPage::validatePage()
{
SettingsManager* sManager = SettingsManager::getInstance();
QString defaultProjectName = sManager->getValue( "default", "ProjectName" )->get().toString();
if ( ui.lineEditName->text().isEmpty() || ui.lineEditName->text() == defaultProjectName )
{
QMessageBox::information( this, tr( "Form is incomplete" ),
tr( "The project name must be filled." ) );
ui.lineEditName->setFocus();
return false;
}
if ( ui.lineEditWorkspace->text().isEmpty() )
{
QMessageBox::information( this, tr( "Form is incomplete" ),
tr( "The workspace location must be set." ) );
ui.lineEditWorkspace->setFocus();
return false;
}
QVariant projectName( ui.lineEditName->text() );
sManager->setValue( "project", "ProjectName", projectName );
return true;
}
void GeneralPage::openWorkspaceDirectory()
{
QString workspace = QFileDialog::getExistingDirectory( this,
"Choose a workspace directory",
QDir::homePath() );
if ( workspace.isEmpty() ) return;
ui.lineEditWorkspace->setText( workspace );
}
void GeneralPage::updateProjectLocation()
{
QString workspacePath = ui.lineEditWorkspace->text();
if ( workspacePath.isEmpty() )
{
ui.lineEditProjectLocation->setText( tr( "Missing workspace location" ) );
ui.lineEditProjectLocation->setPalette( pInvalid );
}
else
{
QString pName = ui.lineEditName->text().replace( ' ', '_' );
QDir workspaceDir( workspacePath );
QDir projectDir( QString( "%1/%2" ).arg( workspacePath, pName ) );
ui.lineEditProjectLocation->setText( projectDir.absolutePath() );
if ( workspaceDir.isRelative() )
{
ui.lineEditProjectLocation->setPalette( pInvalid );
ui.lineEditProjectLocation->setText( tr( "Invalid workspace location" ) );
return;
}
if ( !workspaceDir.exists() )
ui.lineEditProjectLocation->setPalette( pInvalid );
else
{
if ( projectDir.exists() )
ui.lineEditProjectLocation->setPalette( pInvalid );
else
ui.lineEditProjectLocation->setPalette( pValid );
}
}
}
void GeneralPage::setWorkspaceStatus( bool valid )
{
}
#ifndef GENERALPAGE_H
#define GENERALPAGE_H
#include "ui_GeneralPage.h"
class GeneralPage : public QWizardPage
{
Q_OBJECT
public:
GeneralPage( QWidget *parent = 0 );
protected:
virtual void changeEvent( QEvent *e );
virtual int nextId() const;
virtual void initializePage();
virtual bool validatePage();
virtual void cleanupPage();
private slots:
void openWorkspaceDirectory();
void updateProjectLocation();
void setWorkspaceStatus( bool valid );
private:
Ui::GeneralPage ui;
QPalette pValid;
QPalette pInvalid;
};
#endif // GENERALPAGE_H
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <QString> #include <QString>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QWizardPage>
#include "ProjectManager.h" #include "ProjectManager.h"
#include "ProjectWizard.h" #include "ProjectWizard.h"
#include "ProjectPreferences.h" #include "ProjectPreferences.h"
...@@ -33,6 +34,8 @@ ...@@ -33,6 +34,8 @@
#include "PageFactory.h" #include "PageFactory.h"
#include "WelcomePage.h" #include "WelcomePage.h"
#include "OpenPage.h" #include "OpenPage.h"
#include "GeneralPage.h"
#include "VideoPage.h"
#include <QtDebug> #include <QtDebug>
...@@ -50,6 +53,7 @@ ProjectWizard::ProjectWizard( QWidget* parent ) ...@@ -50,6 +53,7 @@ ProjectWizard::ProjectWizard( QWidget* parent )
setPixmap( QWizard::LogoPixmap, logo ); setPixmap( QWizard::LogoPixmap, logo );
setPixmap( QWizard::WatermarkPixmap, QPixmap( ":/images/wizard_watermark" ) ); setPixmap( QWizard::WatermarkPixmap, QPixmap( ":/images/wizard_watermark" ) );
setOption( QWizard::IndependentPages );
setWindowTitle( tr( "Project wizard" ) ); setWindowTitle( tr( "Project wizard" ) );
// Show and connect the help button // Show and connect the help button
...@@ -59,15 +63,13 @@ ProjectWizard::ProjectWizard( QWidget* parent ) ...@@ -59,15 +63,13 @@ ProjectWizard::ProjectWizard( QWidget* parent )
// Create pages // Create pages
QWizardPage* welcomePage = new WelcomePage( this ); QWizardPage* welcomePage = new WelcomePage( this );
QWizardPage* generalPage = PageFactory::generateWizardPage<ProjectPreferences>( "General Settings", this ); QWizardPage* generalPage = new GeneralPage( this );
QWizardPage* videoPage = PageFactory::generateWizardPage<VideoProjectPreferences>( "Video Settings", this ); QWizardPage* videoPage = new VideoPage( this );
QWizardPage* audioPage = PageFactory::generateWizardPage<AudioProjectPreferences>( "Audio Settings", this );
QWizardPage* openPage = new OpenPage( this ); QWizardPage* openPage = new OpenPage( this );
setPage( Page_Welcome, welcomePage ); setPage( Page_Welcome, welcomePage );
setPage( Page_General, generalPage ); setPage( Page_General, generalPage );
setPage( Page_Video, videoPage ); setPage( Page_Video, videoPage );
setPage( Page_Audio, audioPage );
setPage( Page_Open, openPage ); setPage( Page_Open, openPage );
// Set the start page // Set the start page
...@@ -96,24 +98,16 @@ void ProjectWizard::showHelp() ...@@ -96,24 +98,16 @@ void ProjectWizard::showHelp()
void ProjectWizard::accept() void ProjectWizard::accept()
{ {
if ( currentId() == Page_Audio ) if ( currentId() == Page_Video )
{ {
ProjectManager::getInstance()->newProject( field( "projectName" ).toString() );
SettingsManager::getInstance()->commit(); SettingsManager::getInstance()->commit();
} }
if ( WelcomePage::projectPath().length() == 0 )
{
ProjectManager::getInstance()->newProject(
SettingsManager::getInstance()->getValue( "project", "ProjectName" )->get().toString() );
}
emit flush();
QDialog::accept(); QDialog::accept();
return ;
} }
void ProjectWizard::reject() void ProjectWizard::reject()
{ {
SettingsManager::getInstance()->flush(); SettingsManager::getInstance()->flush();
emit flush();
QDialog::reject(); QDialog::reject();
return ;
} }
...@@ -35,7 +35,7 @@ class ProjectWizard : public QWizard ...@@ -35,7 +35,7 @@ class ProjectWizard : public QWizard
public: public:
enum { Page_Welcome, enum { Page_Welcome,
Page_Open, Page_Open,
Page_General, Page_Video, Page_Audio }; Page_General, Page_Video };
ProjectWizard( QWidget* parent = 0 ); ProjectWizard( QWidget* parent = 0 );
~ProjectWizard(); ~ProjectWizard();
...@@ -46,9 +46,6 @@ class ProjectWizard : public QWizard ...@@ -46,9 +46,6 @@ class ProjectWizard : public QWizard
private slots: private slots:
void showHelp(); void showHelp();
signals:
void flush();
}; };
#endif #endif
/*****************************************************************************
* VideoPage.cpp: Wizard page for configuring video settings
*****************************************************************************
* 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 "VideoPage.h"
#include "SettingsManager.h"
VideoPage::VideoPage( QWidget *parent ) :
QWizardPage( parent )
{
ui.setupUi( this );
setTitle( tr( "New project wizard" ) );
setSubTitle( tr( "Configure Video settings" ) );
setFinalPage( true );
connect( ui.comboBoxVideoPresets, SIGNAL( currentIndexChanged(int) ),
this, SLOT( updateVideoPresets() ) );
connect( ui.comboBoxAudioPresets, SIGNAL( currentIndexChanged(int) ),
this, SLOT( updateAudioPresets() ) );
}
void VideoPage::changeEvent( QEvent *e )
{
QWizardPage::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
ui.retranslateUi( this );
break;
default:
break;
}
}
int VideoPage::nextId() const
{
return -1;
}
void VideoPage::initializePage()
{
SettingsManager* sManager = SettingsManager::getInstance();
int projectFps = sManager->getValue( "default",
"VideoProjectFPS" )->get().toDouble();
int projectHeight = sManager->getValue( "default",
"VideoProjectHeight" )->get().toInt();
int projectWidth = sManager->getValue( "default",
"VideoProjectWidth" )->get().toInt();
int sampleRate = sManager->getValue( "default",
"AudioSampleRate" )->get().toInt();
ui.comboBoxVideoPresets->setCurrentIndex( 0 );
ui.comboBoxAudioPresets->setCurrentIndex( 0 );
ui.spinBoxVideoWidth->setValue( projectWidth );
ui.spinBoxVideoHeight->setValue( projectHeight );
ui.doubleSpinBoxVideoFPS->setValue( projectFps );
switch ( sampleRate )
{
case 48000:
ui.comboBoxAudioSamplerate->setCurrentIndex( HZ_48000 );
break;
case 22000:
ui.comboBoxAudioSamplerate->setCurrentIndex( HZ_22000 );
break;
case 11000:
ui.comboBoxAudioSamplerate->setCurrentIndex( HZ_11000 );
break;
case 44000:
default:
ui.comboBoxAudioSamplerate->setCurrentIndex( HZ_44000 );
break;
}
}
bool VideoPage::validatePage()
{
SettingsManager* sManager = SettingsManager::getInstance();
QVariant projectFps( ui.doubleSpinBoxVideoFPS->value() );
QVariant projectHeight( ui.spinBoxVideoHeight->value() );
QVariant projectWidth( ui.spinBoxVideoWidth->value() );
sManager->setValue( "project", "VideoProjectFPS", projectFps );
sManager->setValue( "project", "VideoProjectHeight", projectHeight );
sManager->setValue( "project", "VideoProjectWidth", projectWidth);
return true;
}
void VideoPage::cleanupPage()
{
}
void VideoPage::setVideoFormEnabled( bool enabled )
{
ui.spinBoxVideoWidth->setEnabled( enabled );
ui.spinBoxVideoHeight->setEnabled( enabled );
}
void VideoPage::setAudioFormEnabled( bool enabled )
{
ui.spinBoxAudioChannels->setEnabled( enabled );
ui.comboBoxAudioSamplerate->setEnabled( enabled );
}
void VideoPage::updateVideoPresets()
{
if ( ui.comboBoxVideoPresets->currentIndex() == 0 )
setVideoFormEnabled( true );
else
setVideoFormEnabled( false );
switch ( ui.comboBoxVideoPresets->currentIndex() )
{
case PRESET_VideoCustom: break;
case PRESET_480i:
setVideoResolution( 720, 480 );
break;
case PRESET_576i:
setVideoResolution( 720, 576 );
break;
case PRESET_480p:
setVideoResolution( 720, 480 );
break;
case PRESET_576p:
setVideoResolution( 720, 576 );
break;
case PRESET_720p:
setVideoResolution( 1280, 720 );
break;
case PRESET_1080i:
setVideoResolution( 1920, 1080 );
break;
case PRESET_1080p:
setVideoResolution( 1920, 1080 );
break;
}
}
void VideoPage::updateAudioPresets()
{
if ( ui.comboBoxAudioPresets->currentIndex() == 0 )
setAudioFormEnabled( true );
else
setAudioFormEnabled( false );
switch ( ui.comboBoxAudioPresets->currentIndex() )
{
case PRESET_AudioCustom: break;
case PRESET_STEREO:
ui.spinBoxAudioChannels->setValue( 2 );
break;
case PRESET_MONO:
ui.spinBoxAudioChannels->setValue( 1 );
break;
}
}
void VideoPage::setVideoResolution( int width, int height )
{
ui.spinBoxVideoWidth->setValue( width );
ui.spinBoxVideoHeight->setValue( height );
}
/*****************************************************************************
* VideoPage.h: Wizard page for configuring video settings
*****************************************************************************
* 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 VIDEOPAGE_H
#define VIDEOPAGE_H
#include <QWizardPage>
#include "ui_VideoPage.h"
class VideoPage : public QWizardPage
{
Q_OBJECT
public:
enum SampleRate
{
HZ_48000,
HZ_44000,
HZ_22000,
HZ_11000
};
enum VideoPresets
{
PRESET_VideoCustom,
PRESET_480i, // SDTV/NTSC
PRESET_576i, // SDTV/PAL
PRESET_480p, // EDTV
PRESET_576p, // EDTV
PRESET_720p, // HDTV
PRESET_1080i, // HDTV
PRESET_1080p, // HDTV
};
enum AudioPresets
{
PRESET_AudioCustom,
PRESET_STEREO,
PRESET_MONO
};
VideoPage( QWidget *parent = 0 );
protected:
void changeEvent( QEvent *e );
virtual int nextId() const;
virtual void initializePage();
virtual bool validatePage();
virtual void cleanupPage();
private slots:
void updateVideoPresets();
void updateAudioPresets();
private:
void setVideoFormEnabled( bool enabled );
void setAudioFormEnabled( bool enabled );
void setVideoResolution( int width, int height );
Ui::VideoPage ui;
};
#endif // VIDEOPAGE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralPage</class>
<widget class="QWizardPage" name="GeneralPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<height>316</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="horizontalSpacing">
<number>10</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>This guide will step you through the process of setting up a new project.</string>