Skip to content
Snippets Groups Projects
Commit b78df552 authored by luyikei's avatar luyikei Committed by Hugo Beauzée-Luyssen
Browse files

Implement postLoad/preSave


I find out that if I use connect(Qt::DirectConnection), which its slot is executed in the emitter's thread, I can handle postLoad and preSave functions in each classes gracefully. It is because we can ensure ordering of loading and saving!

Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 3ff2663c
No related branches found
No related tags found
No related merge requests found
......@@ -162,11 +162,13 @@ Settings::loadJsonFrom( const QJsonObject &object )
if ( setValue( it.key(), (*it).toVariant() ) == false )
vlmcWarning() << "Loaded invalid project setting:" << it.key();
}
emit postLoad();
}
void
Settings::saveJsonTo( QJsonObject &object )
{
emit preSave();
for ( const auto& val : m_settings )
{
if ( ( val->flags() & SettingValue::Runtime ) != 0 )
......
......@@ -102,8 +102,9 @@ class QJsonDocument;
VLMC_CREATE_PROJECT_VAR( SettingValue::String, key, defaultValue, "", "", SettingValue::Private )
class Settings
class Settings: public QObject
{
Q_OBJECT
public:
typedef QList<SettingValue*> SettingList;
typedef QMap<QString, SettingValue*> SettingMap;
......@@ -132,6 +133,9 @@ class Settings
QJsonDocument readSettingsFromFile();
void loadJsonFrom( const QJsonObject& object );
void saveJsonTo( QJsonObject& object );
signals:
void postLoad();
void preSave();
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment