From b5955f39b11cd2af2c6c732421555a8e260bf8d5 Mon Sep 17 00:00:00 2001 From: Ludovic Fauvet Date: Thu, 17 Dec 2009 12:20:23 +0100 Subject: [PATCH] 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. --- src/Configuration/VLMCSettingsDefault.cpp | 6 +- src/GUI/wizard/GeneralPage.cpp | 140 +++++++++++ src/GUI/wizard/GeneralPage.h | 30 +++ src/GUI/wizard/ProjectWizard.cpp | 22 +- src/GUI/wizard/ProjectWizard.h | 5 +- src/GUI/wizard/VideoPage.cpp | 186 +++++++++++++++ src/GUI/wizard/VideoPage.h | 80 +++++++ src/GUI/wizard/ui/GeneralPage.ui | 143 +++++++++++ src/GUI/wizard/ui/VideoPage.ui | 277 ++++++++++++++++++++++ src/GUI/wizard/wizard.pri | 12 +- src/Project/ProjectManager.h | 1 + 11 files changed, 880 insertions(+), 22 deletions(-) create mode 100644 src/GUI/wizard/GeneralPage.cpp create mode 100644 src/GUI/wizard/GeneralPage.h create mode 100644 src/GUI/wizard/VideoPage.cpp create mode 100644 src/GUI/wizard/VideoPage.h create mode 100644 src/GUI/wizard/ui/GeneralPage.ui create mode 100644 src/GUI/wizard/ui/VideoPage.ui diff --git a/src/Configuration/VLMCSettingsDefault.cpp b/src/Configuration/VLMCSettingsDefault.cpp index 39bf0d1f0..e3d13c605 100644 --- a/src/Configuration/VLMCSettingsDefault.cpp +++ b/src/Configuration/VLMCSettingsDefault.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "VLMCSettingsDefault.h" #include "SettingsManager.h" @@ -45,7 +46,10 @@ void VLMCSettingsDefault::loadVLMCDefaults( const QString& part ) "VLMCOutPutFPS", defaultOutputPFS ); settingsMan->setValue( part, "VLMCTracksNb", - defaultTrackNb ); + defaultTrackNb ); + settingsMan->setValue( part, + "VLMCWorkspace", + QDir::homePath() ); return ; } diff --git a/src/GUI/wizard/GeneralPage.cpp b/src/GUI/wizard/GeneralPage.cpp new file mode 100644 index 000000000..dbec6fecc --- /dev/null +++ b/src/GUI/wizard/GeneralPage.cpp @@ -0,0 +1,140 @@ +#include +#include +#include + +#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 ) +{ + +} diff --git a/src/GUI/wizard/GeneralPage.h b/src/GUI/wizard/GeneralPage.h new file mode 100644 index 000000000..e27a8336d --- /dev/null +++ b/src/GUI/wizard/GeneralPage.h @@ -0,0 +1,30 @@ +#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 diff --git a/src/GUI/wizard/ProjectWizard.cpp b/src/GUI/wizard/ProjectWizard.cpp index 1a6fe72bf..49f16f070 100644 --- a/src/GUI/wizard/ProjectWizard.cpp +++ b/src/GUI/wizard/ProjectWizard.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "ProjectManager.h" #include "ProjectWizard.h" #include "ProjectPreferences.h" @@ -33,6 +34,8 @@ #include "PageFactory.h" #include "WelcomePage.h" #include "OpenPage.h" +#include "GeneralPage.h" +#include "VideoPage.h" #include @@ -50,6 +53,7 @@ ProjectWizard::ProjectWizard( QWidget* parent ) setPixmap( QWizard::LogoPixmap, logo ); setPixmap( QWizard::WatermarkPixmap, QPixmap( ":/images/wizard_watermark" ) ); + setOption( QWizard::IndependentPages ); setWindowTitle( tr( "Project wizard" ) ); // Show and connect the help button @@ -59,15 +63,13 @@ ProjectWizard::ProjectWizard( QWidget* parent ) // Create pages QWizardPage* welcomePage = new WelcomePage( this ); - QWizardPage* generalPage = PageFactory::generateWizardPage( "General Settings", this ); - QWizardPage* videoPage = PageFactory::generateWizardPage( "Video Settings", this ); - QWizardPage* audioPage = PageFactory::generateWizardPage( "Audio Settings", this ); + QWizardPage* generalPage = new GeneralPage( this ); + QWizardPage* videoPage = new VideoPage( 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 @@ -96,24 +98,16 @@ void ProjectWizard::showHelp() void ProjectWizard::accept() { - if ( currentId() == Page_Audio ) + if ( currentId() == Page_Video ) { + ProjectManager::getInstance()->newProject( field( "projectName" ).toString() ); SettingsManager::getInstance()->commit(); } - if ( WelcomePage::projectPath().length() == 0 ) - { - ProjectManager::getInstance()->newProject( - SettingsManager::getInstance()->getValue( "project", "ProjectName" )->get().toString() ); - } - emit flush(); QDialog::accept(); - return ; } void ProjectWizard::reject() { SettingsManager::getInstance()->flush(); - emit flush(); QDialog::reject(); - return ; } diff --git a/src/GUI/wizard/ProjectWizard.h b/src/GUI/wizard/ProjectWizard.h index 515af5f3e..5b1a9a2f5 100644 --- a/src/GUI/wizard/ProjectWizard.h +++ b/src/GUI/wizard/ProjectWizard.h @@ -35,7 +35,7 @@ class ProjectWizard : public QWizard public: enum { Page_Welcome, Page_Open, - Page_General, Page_Video, Page_Audio }; + Page_General, Page_Video }; ProjectWizard( QWidget* parent = 0 ); ~ProjectWizard(); @@ -46,9 +46,6 @@ class ProjectWizard : public QWizard private slots: void showHelp(); - - signals: - void flush(); }; #endif diff --git a/src/GUI/wizard/VideoPage.cpp b/src/GUI/wizard/VideoPage.cpp new file mode 100644 index 000000000..e3e9c2d82 --- /dev/null +++ b/src/GUI/wizard/VideoPage.cpp @@ -0,0 +1,186 @@ +/***************************************************************************** + * VideoPage.cpp: Wizard page for configuring video settings + ***************************************************************************** + * Copyright (C) 2008-2009 the VLMC team + * + * Authors: Ludovic Fauvet + * + * 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 ); +} diff --git a/src/GUI/wizard/VideoPage.h b/src/GUI/wizard/VideoPage.h new file mode 100644 index 000000000..1a8be40bb --- /dev/null +++ b/src/GUI/wizard/VideoPage.h @@ -0,0 +1,80 @@ +/***************************************************************************** + * VideoPage.h: Wizard page for configuring video settings + ***************************************************************************** + * Copyright (C) 2008-2009 the VLMC team + * + * Authors: Ludovic Fauvet + * + * 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 +#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 diff --git a/src/GUI/wizard/ui/GeneralPage.ui b/src/GUI/wizard/ui/GeneralPage.ui new file mode 100644 index 000000000..a0e7fbe46 --- /dev/null +++ b/src/GUI/wizard/ui/GeneralPage.ui @@ -0,0 +1,143 @@ + + + GeneralPage + + + + 0 + 0 + 542 + 316 + + + + WizardPage + + + + QFormLayout::ExpandingFieldsGrow + + + 10 + + + + + This guide will step you through the process of setting up a new project. + + + false + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Project name + + + + + + + Untitled + + + 200 + + + + + + + Description + + + + + + + + 16777215 + 60 + + + + + + + + + 0 + 30 + + + + Qt::Horizontal + + + + + + + Workspace directory + + + + + + + + + + + 0 + 0 + + + + Browse... + + + + + + + + 0 + 0 + + + + Project location + + + + + + + true + + + + + + + + diff --git a/src/GUI/wizard/ui/VideoPage.ui b/src/GUI/wizard/ui/VideoPage.ui new file mode 100644 index 000000000..f4430dec7 --- /dev/null +++ b/src/GUI/wizard/ui/VideoPage.ui @@ -0,0 +1,277 @@ + + + VideoPage + + + + 0 + 0 + 546 + 445 + + + + WizardPage + + + + + + + 0 + 0 + + + + In this page you can fine tune some of the settings of your new project. + + + true + + + + + + + Video + + + + + + Width + + + + + + + Height + + + + + + + + Custom + + + + + SDTV/NTSC (480i) + + + + + SDTV/PAL (576i) + + + + + EDTV (480p) + + + + + EDTV (576p) + + + + + HDTV (720p) + + + + + HDTV (1080i) + + + + + HDTV (1080p) + + + + + + + + 1 + + + 1920 + + + 720 + + + + + + + 1 + + + 1080 + + + 480 + + + + + + + Frames / sec + + + + + + + 2 + + + 72.000000000000000 + + + 25.000000000000000 + + + + + + + + + + Audio + + + + + + Number of channels + + + + + + + 1 + + + 2 + + + 2 + + + + + + + + Custom + + + + + Stereo + + + + + Mono + + + + + + + + Sample rate + + + + + + + 1 + + + + 48000 Hz + + + + + 44000 Hz + + + + + 22000 Hz + + + + + 11000 Hz + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 20 + 30 + + + + + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 20 + 30 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/GUI/wizard/wizard.pri b/src/GUI/wizard/wizard.pri index 4e583a249..8b30c772a 100644 --- a/src/GUI/wizard/wizard.pri +++ b/src/GUI/wizard/wizard.pri @@ -2,10 +2,16 @@ HEADERS += CustomWizardPage.h \ WelcomePage.h \ PageFactory.h \ ProjectWizard.h \ - OpenPage.h + OpenPage.h \ + GeneralPage.h \ + VideoPage.h SOURCES += CustomWizardPage.cpp \ WelcomePage.cpp \ ProjectWizard.cpp \ - OpenPage.cpp + OpenPage.cpp \ + GeneralPage.cpp \ + VideoPage.cpp FORMS += ui/WelcomePage.ui \ - ui/OpenPage.ui + ui/OpenPage.ui \ + ui/GeneralPage.ui \ + ui/VideoPage.ui diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h index 359cff9ab..13846de0e 100644 --- a/src/Project/ProjectManager.h +++ b/src/Project/ProjectManager.h @@ -71,6 +71,7 @@ private: bool m_needSave; QStringList m_recentsProjects; QString m_projectName; + QString m_projectDescription; friend class Singleton; -- GitLab