aboutsummaryrefslogtreecommitdiff
path: root/lib/settings.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-04-04 21:27:38 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-04-06 20:32:48 +0900
commit432e7fd7107d8260e0016a1adcd8d94263dc1044 (patch)
tree71171a541e508f7a97b1d843c707c7ef296374cb /lib/settings.cpp
parent8035ec464ce797abab5e464c2cfb485f7fa14d06 (diff)
downloadlibquotient-432e7fd7107d8260e0016a1adcd8d94263dc1044.tar.gz
libquotient-432e7fd7107d8260e0016a1adcd8d94263dc1044.zip
Clean up on clang-tidy/clazy analysis
Diffstat (limited to 'lib/settings.cpp')
-rw-r--r--lib/settings.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/settings.cpp b/lib/settings.cpp
index 852e19cb..124d7042 100644
--- a/lib/settings.cpp
+++ b/lib/settings.cpp
@@ -84,18 +84,21 @@ void SettingsGroup::remove(const QString& key)
Settings::remove(fullKey);
}
-QMC_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", "", setDeviceId)
-QMC_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", "", setDeviceName)
+QMC_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {}, setDeviceId)
+QMC_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {}, setDeviceName)
QMC_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false, setKeepLoggedIn)
+static const auto HomeserverKey = QStringLiteral("homeserver");
+static const auto AccessTokenKey = QStringLiteral("access_token");
+
QUrl AccountSettings::homeserver() const
{
- return QUrl::fromUserInput(value("homeserver").toString());
+ return QUrl::fromUserInput(value(HomeserverKey).toString());
}
void AccountSettings::setHomeserver(const QUrl& url)
{
- setValue("homeserver", url.toString());
+ setValue(HomeserverKey, url.toString());
}
QString AccountSettings::userId() const
@@ -105,19 +108,19 @@ QString AccountSettings::userId() const
QString AccountSettings::accessToken() const
{
- return value("access_token").toString();
+ return value(AccessTokenKey).toString();
}
void AccountSettings::setAccessToken(const QString& accessToken)
{
qCWarning(MAIN) << "Saving access_token to QSettings is insecure."
" Developers, please save access_token separately.";
- setValue("access_token", accessToken);
+ setValue(AccessTokenKey, accessToken);
}
void AccountSettings::clearAccessToken()
{
- legacySettings.remove("access_token");
- legacySettings.remove("device_id"); // Force the server to re-issue it
- remove("access_token");
+ legacySettings.remove(AccessTokenKey);
+ legacySettings.remove(QStringLiteral("device_id")); // Force the server to re-issue it
+ remove(AccessTokenKey);
}