Commit 184dad75 authored by Clement CHAVANCE's avatar Clement CHAVANCE

Settings Refactor continue

parent 80d03f8a
......@@ -3,6 +3,7 @@
void ProjectSettingsDefault::load( void )
{
SettingsManager::getInstance()->addNewSettingsPart( "default" );
ProjectSettingsDefault::loadAudioDefaults();
ProjectSettingsDefault::loadVideoDefaults();
ProjectSettingsDefault::loadProjectDefaults();
......
......@@ -143,8 +143,13 @@ void SettingsManager::loadSettings( const QDomElement& settings )
void SettingsManager::addNewSettingsPart( const QString& name )
{
QWriteLocker lock( &m_globalLock );
m_data.insert( name, new SettingsPart );
QReadLocker rLock( &m_globalLock );
if ( !m_data.contains( name ) )
{
rLock.unlock();
QWriteLocker lock( &m_globalLock );
m_data.insert( name, new SettingsPart );
}
}
void SettingsManager::loadDefaultsSettings()
......
......@@ -5,6 +5,7 @@
void VLMCSettingsDefault::load( void )
{
SettingsManager::getInstance()->addNewSettingsPart( "default" );
VLMCSettingsDefault::loadVLMCDefaults();
VLMCSettingsDefault::loadlanguageDefaults();
......
......@@ -25,10 +25,10 @@
#include "QDebug"
AudioProjectPreferences::AudioProjectPreferences( QWidget *parent )
: PreferenceWidget( parent )
AudioProjectPreferences::AudioProjectPreferences( QWidget *parent )
: PreferenceWidget( parent )
{
m_ui.setupUi( this );
m_ui.setupUi( this );
}
AudioProjectPreferences::~AudioProjectPreferences() { }
......@@ -41,7 +41,7 @@ void AudioProjectPreferences::load()
return ;
}
void AudioProjectPreferences::save( QHash<QString, QVariant>& settings )
void AudioProjectPreferences::save()
{
//settings.insert( "AudioSampleRate", m_ui.SampleRate->value() );
return ;
......
......@@ -35,7 +35,7 @@ class AudioProjectPreferences : public PreferenceWidget
AudioProjectPreferences( QWidget *parent = 0 );
~AudioProjectPreferences();
void load();
void save( QHash<QString, QVariant>& settings );
void save();
private:
Ui::AudioProjectPreferences m_ui;
};
......
......@@ -26,6 +26,18 @@
PreferenceWidget::PreferenceWidget( QWidget* parent )
: QWidget( parent )
: QWidget( parent ),
m_defaults( false ),
m_settName( "" )
{
}
void PreferenceWidget::setDefaults( bool defaults )
{
m_defaults = defaults;
}
void PreferenceWidget::setName( const QString& name )
{
m_settName = name;
}
......@@ -36,8 +36,15 @@ class PreferenceWidget : public QWidget
PreferenceWidget( QWidget* parent = 0 );
virtual ~PreferenceWidget() {}
void setDefaults( bool defaults );
void setName( const QString& name );
virtual void load() = 0;
virtual void save( QHash<QString, QVariant>& settings ) = 0;
virtual void save() = 0;
private:
bool m_defaults;
QString m_settName;
};
#endif
......@@ -48,7 +48,7 @@ void ProjectPreferences::load()
//m_ui.ProjectDirectoryLineEdit->setText( Dir );
}
void ProjectPreferences::save( QHash<QString, QVariant>& settings )
void ProjectPreferences::save()
{
//settings.insert( "ProjectName", QVariant( m_ui.ProjectNameLineEdit->text() ) );
//settings.insert( "ProjectDirectory", QVariant( m_ui.ProjectDirectoryLineEdit->text() ) );
......
......@@ -36,7 +36,7 @@ class ProjectPreferences : public PreferenceWidget
ProjectPreferences( QWidget* parent = 0 );
virtual ~ProjectPreferences();
void load();
void save( QHash<QString, QVariant>& settings );
void save();
private:
Ui::ProjectPreferences m_ui;
};
......
......@@ -37,24 +37,18 @@
#include "Panel.h"
Settings::Settings( bool loadDefaults, QWidget* parent, Qt::WindowFlags f )
Settings::Settings( bool loadDefaults,
const QString& name,
QWidget* parent,
Qt::WindowFlags f )
: QDialog( parent, f ),
m_currentWidget( NULL ),
m_defaults( loadDefaults )
m_defaults( loadDefaults ),
m_name( name )
{
m_panel = new Panel( this );
m_stackedWidgets = new QStackedWidget( this );
QObject::connect( m_panel,
SIGNAL( changePanel( int ) ),
SLOT( switchWidget( int ) ) );
QObject::connect( this,
SIGNAL( widgetSwitched( int ) ),
m_stackedWidgets,
SLOT( setCurrentIndex( int ) ));
QObject::connect( SettingsManager::getInstance(),
SIGNAL( settingsLoaded() ),
this,
SLOT( load() ) );
SettingsManager::getInstance()->addNewSettingsPart( m_name );
}
Settings::~Settings()
......@@ -92,6 +86,20 @@ void Settings::build()
hLayout->insertLayout( 1, buildRightHLayout() );
}
void Settings::connect( void )
{
QObject::connect( m_panel,
SIGNAL( changePanel( int ) ),
SLOT( switchWidget( int ) ) );
QObject::connect( this,
SIGNAL( widgetSwitched( int ) ),
m_stackedWidgets,
SLOT( setCurrentIndex( int ) ));
QObject::connect( SettingsManager::getInstance(),
SIGNAL( settingsLoaded() ),
this,
SLOT( load() ) );
}
QVBoxLayout* Settings::buildRightHLayout()
{
......@@ -141,6 +149,7 @@ void Settings::buttonClicked( QAbstractButton* button )
break;
case QDialogButtonBox::Cancel :
hide = true;
load();
break;
case QDialogButtonBox::Apply :
save = true;
......@@ -152,18 +161,13 @@ void Settings::buttonClicked( QAbstractButton* button )
{
qDebug() << "Saving Preferences";
//Save Settings
QHash<QString, QVariant> sett;
PreferenceWidget* widg;
foreach( widg, m_pWidgets )
widg->save( sett );
qDebug() << sett;
//SettingsManager::getInstance()->setValues( sett );
widg->save();
}
if ( hide == true )
{
setVisible( false );
}
}
void Settings::switchWidget( int widget )
......@@ -181,5 +185,5 @@ void Settings::load()
{
PreferenceWidget* pwidg;
foreach( pwidg, m_pWidgets )
pwidg->load();
pwidg->load( );
}
......@@ -43,7 +43,10 @@ class Settings : public QDialog
Q_DISABLE_COPY( Settings )
public:
Settings( bool loadDefaults = false, QWidget* parent = 0, Qt::WindowFlags f = 0 );
Settings( bool loadDefaults = false,
const QString& name = "default",
QWidget* parent = 0,
Qt::WindowFlags f = 0 );
virtual ~Settings();
void addWidget( const QString& name,
PreferenceWidget* pWidget,
......@@ -52,6 +55,7 @@ class Settings : public QDialog
void build();
private:
void connect( void );
QVBoxLayout* buildRightHLayout();
void save( void );
......@@ -64,6 +68,7 @@ class Settings : public QDialog
QStackedWidget* m_stackedWidgets;
QDialogButtonBox* m_buttons;
bool m_defaults;
QString m_name;
public slots:
......
......@@ -46,7 +46,7 @@ void VLMCPreferences::load()
//
}
void VLMCPreferences::save( QHash<QString, QVariant>& settings )
void VLMCPreferences::save()
{
// settings.insert( "VLMCOutPutFPS", QVariant( m_ui.outputFPS->text() ) );
// settings.insert( "VLMCPreviewFPS", QVariant( m_ui.previewFPS->text() ) );
......
......@@ -35,7 +35,7 @@ class VLMCPreferences : public PreferenceWidget
VLMCPreferences( QWidget *parent = 0 );
~VLMCPreferences();
void load();
void save( QHash<QString, QVariant>& settings );
void save();
private:
Ui::VLMCPreferences m_ui;
};
......
......@@ -45,7 +45,7 @@ void VideoProjectPreferences::load()
// m_ui.WidthSpinBox->setValue( projectWidth );
}
void VideoProjectPreferences::save( QHash<QString, QVariant>& settings )
void VideoProjectPreferences::save()
{
// settings.insert( "VideoProjectFPS", QVariant( m_ui.FPSSpinBox->value() ) );
// settings.insert( "VideoProjectHeight", QVariant( m_ui.HeightSpinBox->value() ) );
......
......@@ -35,7 +35,7 @@ class VideoProjectPreferences : public PreferenceWidget
VideoProjectPreferences( QWidget *parent = 0 );
~VideoProjectPreferences();
void load();
void save( QHash<QString, QVariant>& settings );
void save();
private:
Ui::VideoProjectPreferences m_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