Commit 1fc3fa98 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Wizzard: Don't modify settings until the entire wizzard has been validated.

Fixes #56
parent 3a4398a6
......@@ -49,6 +49,7 @@ GeneralPage::GeneralPage( QWidget *parent ) :
this, SLOT( updateProjectLocation() ) );
registerField( "projectName*", ui.lineEditName );
registerField( "workspace*", ui.lineEditProjectLocation );
}
void
......@@ -94,8 +95,6 @@ GeneralPage::validatePage()
{
if ( m_valid == false )
return false;
SettingsManager *sManager = SettingsManager::getInstance();
const QString &defaultProjectName = ProjectManager::unNamedProject;
if ( ui.lineEditName->text().isEmpty() ||
ui.lineEditName->text() == defaultProjectName )
......@@ -113,16 +112,12 @@ GeneralPage::validatePage()
return false;
}
QVariant projectName( ui.lineEditName->text() );
sManager->setValue( "general/ProjectName", projectName, SettingsManager::Project );
//Create the project directory in the workspace dir.
QString projectPath = ui.lineEditName->text().replace( ' ', '_' );
QDir workspaceDir( ui.lineEditWorkspace->text() );
if ( workspaceDir.exists( projectPath ) == false )
workspaceDir.mkdir( projectPath );
sManager->setValue( "general/Workspace", ui.lineEditProjectLocation->text(), SettingsManager::Project );
return true;
}
......
......@@ -93,8 +93,20 @@ void ProjectWizard::showHelp()
void ProjectWizard::accept()
{
//This intend to check if the user opened a project, or created one.
//If he was creating a project, the current page will be the video/audio settings one.
if ( currentId() == Page_Video )
{
SettingsManager *sManager = SettingsManager::getInstance();
GUIProjectManager::getInstance()->newProject( field( "projectName" ).toString() );
sManager->setValue( "general/Workspace", field( "workspace" ), SettingsManager::Project );
sManager->setValue( "video/VLMCOutputFPS", field( "fps" ), SettingsManager::Project );
sManager->setValue( "video/VideoProjectHeight", field( "height" ), SettingsManager::Project );
sManager->setValue( "video/VideoProjectWidth", field( "width" ), SettingsManager::Project );
sManager->setValue( "audio/AudioSampleRate", field( "samplerate" ), SettingsManager::Project );
sManager->setValue( "audio/NbChannels", field( "samplerate" ), SettingsManager::Project );
}
QDialog::accept();
}
......
......@@ -37,6 +37,11 @@ VideoPage::VideoPage( QWidget* parent ) :
this, SLOT( updateVideoPresets() ) );
connect( ui.comboBoxAudioPresets, SIGNAL( currentIndexChanged(int) ),
this, SLOT( updateAudioPresets() ) );
registerField( "fps", ui.doubleSpinBoxVideoFPS );
registerField( "width", ui.spinBoxVideoWidth );
registerField( "height", ui.spinBoxVideoHeight );
registerField( "samplerate", ui.comboBoxAudioSamplerate );
registerField( "channels", ui.spinBoxAudioChannels );
}
void
......@@ -94,15 +99,6 @@ VideoPage::initializePage()
bool
VideoPage::validatePage()
{
SettingsManager* sManager = SettingsManager::getInstance();
QVariant projectFps( ui.doubleSpinBoxVideoFPS->value() );
QVariant projectHeight( ui.spinBoxVideoHeight->value() );
QVariant projectWidth( ui.spinBoxVideoWidth->value() );
sManager->setValue( "video/VLMCOutputFPS", projectFps, SettingsManager::Project );
sManager->setValue( "video/VideoProjectHeight", projectHeight, SettingsManager::Project );
sManager->setValue( "video/VideoProjectWidth", projectWidth, SettingsManager::Project );
return true;
}
......
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