diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-03 17:53:23 +0300 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-03 17:53:23 +0300 |
commit | 02fa295085ae2297062d10f476a0b40b7fcb2559 (patch) | |
tree | cfdeb3da9e25be1e0bd0da68ae71b9869573fcdd /settings.h | |
parent | 352810b5945d4994369379c568eb48dd41071776 (diff) | |
download | libquotient-02fa295085ae2297062d10f476a0b40b7fcb2559.tar.gz libquotient-02fa295085ae2297062d10f476a0b40b7fcb2559.zip |
Provide facilities to migrate from legacy settings location
This is for a case of renaming an organisation or an application
Diffstat (limited to 'settings.h')
-rw-r--r-- | settings.h | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -28,7 +28,17 @@ namespace QMatrixClient {
class Settings: public QSettings
{
+ Q_OBJECT
public:
+ /**
+ * Use this function before creating any Settings objects in order
+ * to setup a read-only location where configuration has previously
+ * been stored. This will provide an additional fallback in case of
+ * renaming the organisation/application.
+ */
+ static void setLegacyNames(const QString& organizationName,
+ const QString& applicationName = {});
+
#if defined(_MSC_VER) && _MSC_VER < 1900
// VS 2013 (and probably older) aren't friends with 'using' statements
// that involve private constructors
@@ -41,6 +51,16 @@ namespace QMatrixClient const QVariant &value);
Q_INVOKABLE QVariant value(const QString &key,
const QVariant &defaultValue = {}) const;
+ Q_INVOKABLE bool contains(const QString& key) const;
+ Q_INVOKABLE QStringList childGroups() const;
+
+ private:
+ static QString legacyOrganizationName;
+ static QString legacyApplicationName;
+
+ protected:
+ const QSettings legacySettings { legacyOrganizationName,
+ legacyApplicationName };
};
class SettingsGroup: public Settings
@@ -69,7 +89,7 @@ namespace QMatrixClient class AccountSettings: public SettingsGroup
{
Q_OBJECT
- Q_PROPERTY(QString userId READ userId)
+ Q_PROPERTY(QString userId READ userId CONSTANT)
Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId)
Q_PROPERTY(QString deviceName READ deviceName WRITE setDeviceName)
Q_PROPERTY(QUrl homeserver READ homeserver WRITE setHomeserver)
|