diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2019-01-24 10:30:42 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-02-01 16:23:49 +0000 |
commit | f82c8ed1ef7b0f1150efe481a247260c382179c0 (patch) | |
tree | 7b63001e7205a0e6fb026e5399d83c6b69c09884 /src/imports | |
parent | 4b0a030cc9b9fa32383a43e2b971f05a536b8e7f (diff) |
Add Settings.sync method
This matches QSettings.sync
Change-Id: Ife73e16c23e1b03f7539fac70ea0a71b76bd3aca
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/settings/qqmlsettings.cpp | 19 | ||||
-rw-r--r-- | src/imports/settings/qqmlsettings_p.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index f7a7d8b055..287a70363a 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -487,6 +487,25 @@ void QQmlSettings::setValue(const QString &key, const QVariant &value) qCDebug(lcSettings) << "QQmlSettings: setValue" << key << ":" << value; } +/*! + \qmlmethod Settings::sync() + + Writes any unsaved changes to permanent storage, and reloads any + settings that have been changed in the meantime by another + application. + + This function is called automatically from QSettings's destructor and + by the event loop at regular intervals, so you normally don't need to + call it yourself. + + \sa QSettings::sync +*/ +void QQmlSettings::sync() +{ + Q_D(QQmlSettings); + d->instance()->sync(); +} + void QQmlSettings::classBegin() { } diff --git a/src/imports/settings/qqmlsettings_p.h b/src/imports/settings/qqmlsettings_p.h index f9122a58f7..a86c8b4751 100644 --- a/src/imports/settings/qqmlsettings_p.h +++ b/src/imports/settings/qqmlsettings_p.h @@ -79,6 +79,7 @@ public: Q_INVOKABLE QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const; Q_INVOKABLE void setValue(const QString &key, const QVariant &value); + Q_INVOKABLE void sync(); protected: void timerEvent(QTimerEvent *event) override; |