Commit f514da4a authored by Clement CHAVANCE's avatar Clement CHAVANCE Committed by Vincent Carrubba

settings are now saved when loading a project file

parent c4aadfb9
......@@ -76,11 +76,9 @@ void SettingsManager::saveSettings( QDomDocument& xmlfile, QDomElement& root )
QDomElement settingsNode = xmlfile.createElement( "settings" );
for ( ; it != end; ++it )
{
//DEBUG
{
qDebug() << it.key() << "val" << it.value().toString();
}
settingsNode.setAttribute( it.key(), it.value().toString() );
QDomElement elem = xmlfile.createElement( it.key() );
elem.setAttribute( "value", it.value().toString() );
settingsNode.appendChild( elem );
}
m_lock.unlock();
......@@ -114,9 +112,10 @@ void SettingsManager::loadSettings( const QDomElement& settings )
qWarning() << "Invalid number of attributes for" << list.at( idx ).nodeName();
return ;
}
m_data.insert( attrMap.item( 0 ).nodeName(),
m_data.insert( list.at( idx ).toElement().tagName(),
QVariant( attrMap.item( 0 ).nodeValue() ));
}
m_lock.unlock();
//TODO : notify the widget that values have been loaded
emit settingsLoaded( m_data );
}
......@@ -37,6 +37,7 @@
class SettingsManager : public QObject, public QSingleton<SettingsManager>
{
Q_OBJECT
Q_DISABLE_COPY( SettingsManager )
friend class QSingleton<SettingsManager>;
public:
......@@ -52,6 +53,9 @@ class SettingsManager : public QObject, public QSingleton<SettingsManager>
QHash<QString, QVariant> m_data;
mutable QReadWriteLock m_lock;
signals:
void settingsLoaded( const QHash<QString, QVariant>& settings );
};
......
......@@ -65,6 +65,10 @@ void Settings::addWidget( const QString& name,
const QString& label )
{
m_stackedWidgets->addWidget( pWidget );
QObject::connect( SettingsManager::getInstance(),
SIGNAL( settingsLoaded( const QHash<QString, QVariant>& ) ),
this,
SLOT( loadSettings( const QHash<QString, QVariant>& ) ) );
int idx = m_stackedWidgets->indexOf( pWidget );
m_widgets.insert( idx, name );
......@@ -170,3 +174,7 @@ void Settings::switchWidget( int widget )
m_title->setText( m_widgets.value( widget ) );
emit widgetSwitched( widget );
}
void Settings::loadSettings( const QHash<QString, QVariant>& sett )
{
}
......@@ -67,6 +67,7 @@ class Settings : public QDialog
public slots:
void switchWidget( int widget );
void loadSettings( const QHash<QString, QVariant>& );
private slots:
void buttonClicked( QAbstractButton* button );
......
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