aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-09-29 17:50:28 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-09-29 17:51:20 +0900
commitbe53652eb30edd6e096c172a97609070d1e74746 (patch)
tree43c50381ad2bc851fd1351bb321ed5d1b8e170d1 /lib
parent8f1bfa5c5764e399259c13b260661647363cf5d9 (diff)
downloadlibquotient-be53652eb30edd6e096c172a97609070d1e74746.tar.gz
libquotient-be53652eb30edd6e096c172a97609070d1e74746.zip
Settings: childGroups() should merge legacy and current groups; QMC->QTNT in macros
Because otherwise migrating one group to the current location leads to all other groups suddenly disappearing from Settings view.
Diffstat (limited to 'lib')
-rw-r--r--lib/networksettings.cpp6
-rw-r--r--lib/networksettings.h6
-rw-r--r--lib/settings.cpp11
-rw-r--r--lib/settings.h10
4 files changed, 18 insertions, 15 deletions
diff --git a/lib/networksettings.cpp b/lib/networksettings.cpp
index cb071483..40ecba11 100644
--- a/lib/networksettings.cpp
+++ b/lib/networksettings.cpp
@@ -26,9 +26,9 @@ void NetworkSettings::setupApplicationProxy() const
{ proxyType(), proxyHostName(), proxyPort() });
}
-QMC_DEFINE_SETTING(NetworkSettings, QNetworkProxy::ProxyType, proxyType,
+QTNT_DEFINE_SETTING(NetworkSettings, QNetworkProxy::ProxyType, proxyType,
"proxy_type", QNetworkProxy::DefaultProxy, setProxyType)
-QMC_DEFINE_SETTING(NetworkSettings, QString, proxyHostName, "proxy_hostname",
+QTNT_DEFINE_SETTING(NetworkSettings, QString, proxyHostName, "proxy_hostname",
{}, setProxyHostName)
-QMC_DEFINE_SETTING(NetworkSettings, quint16, proxyPort, "proxy_port", -1,
+QTNT_DEFINE_SETTING(NetworkSettings, quint16, proxyPort, "proxy_port", -1,
setProxyPort)
diff --git a/lib/networksettings.h b/lib/networksettings.h
index a6a13f93..2399cf5f 100644
--- a/lib/networksettings.h
+++ b/lib/networksettings.h
@@ -27,9 +27,9 @@ Q_DECLARE_METATYPE(QNetworkProxy::ProxyType)
namespace Quotient {
class NetworkSettings : public SettingsGroup {
Q_OBJECT
- QMC_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType)
- QMC_DECLARE_SETTING(QString, proxyHostName, setProxyHostName)
- QMC_DECLARE_SETTING(quint16, proxyPort, setProxyPort)
+ QTNT_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType)
+ QTNT_DECLARE_SETTING(QString, proxyHostName, setProxyHostName)
+ QTNT_DECLARE_SETTING(quint16, proxyPort, setProxyPort)
Q_PROPERTY(QString proxyHost READ proxyHostName WRITE setProxyHostName)
public:
template <typename... ArgTs>
diff --git a/lib/settings.cpp b/lib/settings.cpp
index 3bf61605..0349e699 100644
--- a/lib/settings.cpp
+++ b/lib/settings.cpp
@@ -49,7 +49,10 @@ bool Settings::contains(const QString& key) const
QStringList Settings::childGroups() const
{
auto l = QSettings::childGroups();
- return !l.isEmpty() ? l : legacySettings.childGroups();
+ for (const auto& g: legacySettings.childGroups())
+ if (!l.contains(g))
+ l.push_back(g);
+ return l;
}
void SettingsGroup::setValue(const QString& key, const QVariant& value)
@@ -88,11 +91,11 @@ void SettingsGroup::remove(const QString& key)
Settings::remove(fullKey);
}
-QMC_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {},
+QTNT_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {},
setDeviceId)
-QMC_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {},
+QTNT_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {},
setDeviceName)
-QMC_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false,
+QTNT_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false,
setKeepLoggedIn)
static const auto HomeserverKey = QStringLiteral("homeserver");
diff --git a/lib/settings.h b/lib/settings.h
index d317ec2a..79ebba6c 100644
--- a/lib/settings.h
+++ b/lib/settings.h
@@ -119,7 +119,7 @@ private:
QString groupPath;
};
-#define QMC_DECLARE_SETTING(type, propname, setter) \
+#define QTNT_DECLARE_SETTING(type, propname, setter) \
Q_PROPERTY(type propname READ propname WRITE setter) \
public: \
type propname() const; \
@@ -127,7 +127,7 @@ public: \
\
private:
-#define QMC_DEFINE_SETTING(classname, type, propname, qsettingname, \
+#define QTNT_DEFINE_SETTING(classname, type, propname, qsettingname, \
defaultValue, setter) \
type classname::propname() const \
{ \
@@ -142,9 +142,9 @@ private:
class AccountSettings : public SettingsGroup {
Q_OBJECT
Q_PROPERTY(QString userId READ userId CONSTANT)
- QMC_DECLARE_SETTING(QString, deviceId, setDeviceId)
- QMC_DECLARE_SETTING(QString, deviceName, setDeviceName)
- QMC_DECLARE_SETTING(bool, keepLoggedIn, setKeepLoggedIn)
+ QTNT_DECLARE_SETTING(QString, deviceId, setDeviceId)
+ QTNT_DECLARE_SETTING(QString, deviceName, setDeviceName)
+ QTNT_DECLARE_SETTING(bool, keepLoggedIn, setKeepLoggedIn)
/** \deprecated \sa setAccessToken */
Q_PROPERTY(QString accessToken READ accessToken WRITE setAccessToken)
Q_PROPERTY(QByteArray encryptionAccountPickle READ encryptionAccountPickle