Commit 8484c3db authored by Clement CHAVANCE's avatar Clement CHAVANCE

Preferences are now saved when user click on a button

parent f95c5407
......@@ -26,12 +26,12 @@
int SettingsManager::createNewSettings()
{
this->m_settings.append(new SettingsContainer());
return this->m_settings.size() - 1;
this->m_settings.append(new SettingsContainer());
return this->m_settings.size() - 1;
}
SettingsManager::SettingsManager( QObject* parent )
: QObject( parent )
SettingsManager::SettingsManager( QObject* parent )
: QObject( parent )
{
}
......@@ -41,9 +41,10 @@ SettingsManager::~SettingsManager()
void SettingsManager::saveSettings( QDomDocument& xmlfile, int index )
{
SettingsContainer* settings = m_settings[index];
settings->lock.lockForRead();
Q_UNUSED( xmlfile )
SettingsContainer* settings = m_settings[index];
settings->lock.lockForRead();
//SAVE SETTINGS TO DomDocument
settings->lock.unlock();
//SAVE SETTINGS TO DomDocument
settings->lock.unlock();
}
......@@ -35,29 +35,29 @@
struct SettingsContainer
{
QReadWriteLock lock;
QHash<QString, QVariant> settings;
QReadWriteLock lock;
QHash<QString, QVariant> settings;
};
class SettingsManager : public QObject, public QSingleton<SettingsManager>
{
//Q_OBJECT
//
friend class QSingleton<SettingsManager>;
public:
int createNewSettings();
//Q_OBJECT
//
friend class QSingleton<SettingsManager>;
public:
int createNewSettings();
void setValues( QHash<QString, QVariant>, int index );
void setValue( const QString& key, QVariant& value, int index );
QVariant& getValue( const QString& key );
private:
SettingsManager( QObject* parent = 0 );
~SettingsManager();
void setValues( QHash<QString, QVariant>, int index );
void setValue( const QString& key, QVariant& value, int index );
QVariant& getValue( const QString& key );
private:
SettingsManager( QObject* parent = 0 );
~SettingsManager();
QVector<SettingsContainer*> m_settings;
QVector<SettingsContainer*> m_settings;
public slots:
void saveSettings( QDomDocument& xmlfile, int index );
public slots:
void saveSettings( QDomDocument& xmlfile, int index );
};
......
......@@ -29,7 +29,7 @@
#include "PreferenceWidget.h"
ProjectPreferences::ProjectPreferences( QWidget* parent )
ProjectPreferences::ProjectPreferences( QWidget* parent )
: PreferenceWidget( parent )
{
m_ui.setupUi( this );
......
......@@ -69,6 +69,7 @@ void Settings::addWidget( const QString& name,
int idx = m_stackedWidgets->indexOf( pWidget );
m_widgets.insert( idx, name );
m_pWidgets.push_back( pWidget );
m_panel->addButton( label, icon, idx );
if ( !m_currentWidget )
m_currentWidget = pWidget;
......@@ -144,12 +145,14 @@ void Settings::buttonClicked( QAbstractButton* button )
}
if ( save == true )
{
qDebug() << "Saving Preferences";
//Save Settings
QHash<QString, QVariant> sett;
PreferenceWidget* widg;
foreach( widg, m_pWidgets )
widg->save( sett );
qDebug() << sett;
}
if ( hide == true )
{
......
......@@ -40,7 +40,7 @@ bool VLMCPreferences::load()
void VLMCPreferences::save( QHash<QString, QVariant>& settings )
{
settings.insert( "VLMCOutPutFPS", QVariant( m_ui.outputFPS->text() ) );
settings.insert( "VLMCPreviewFPS", QVariant( m_ui.previewFPS->text() ) );
settings.insert( "VLMCTracksNb", QVariant( m_ui.tracksNb->text() ) );
settings.insert( "VLMCOutPutFPS", QVariant( m_ui.outputFPS->text() ) );
settings.insert( "VLMCPreviewFPS", QVariant( m_ui.previewFPS->text() ) );
settings.insert( "VLMCTracksNb", QVariant( m_ui.tracksNb->text() ) );
}
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