[vlmc-devel] Restores settings to default values on closing project
Barun Parruck
git at videolan.org
Fri Mar 11 11:20:24 CET 2016
vlmc | branch: master | Barun Parruck <barun.parruck at gmail.com> | Thu Mar 10 21:03:58 2016 +0530| [52614dfa49fa45f27cdc6ba07fd3c467aed2c4dd] | committer: Hugo Beauzée-Luyssen
Restores settings to default values on closing project
Settings are now restored to default values when a project is closed.
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> https://code.videolan.org/videolan/vlmc/commit/52614dfa49fa45f27cdc6ba07fd3c467aed2c4dd
---
src/Project/Project.cpp | 2 +-
src/Settings/Settings.cpp | 10 +++++++++-
src/Settings/Settings.h | 1 +
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index dee00e9..0401154 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -266,7 +266,7 @@ Project::closeProject()
{
if ( m_projectFile == nullptr )
return;
- // FIXME: Restore settings to their default value
+ m_settings->restoreDefaultValues();
emit projectClosed();
delete m_projectFile;
m_projectFile = nullptr;
diff --git a/src/Settings/Settings.cpp b/src/Settings/Settings.cpp
index 2259228..c1f97ad 100644
--- a/src/Settings/Settings.cpp
+++ b/src/Settings/Settings.cpp
@@ -164,7 +164,15 @@ Settings::setValue(const QString &key, const QVariant &value)
Q_ASSERT_X( false, __FILE__, "setting value without a created variable" );
return false;
}
-
+void
+Settings::restoreDefaultValues()
+{
+ QReadLocker lock( &m_rwLock );
+ for (auto s : m_settings)
+ {
+ s->restoreDefault();
+ }
+}
SettingValue*
Settings::value(const QString &key)
{
diff --git a/src/Settings/Settings.h b/src/Settings/Settings.h
index 65d368a..b53533b 100644
--- a/src/Settings/Settings.h
+++ b/src/Settings/Settings.h
@@ -122,6 +122,7 @@ class Settings : public ILoadSave
bool load();
bool save();
bool save( QXmlStreamWriter& project );
+ void restoreDefaultValues();
void setSettingsFile( const QString& settingsFile );
bool load( const QDomDocument& document );
More information about the Vlmc-devel
mailing list