aboutsummaryrefslogtreecommitdiff
path: root/lib/settings.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/settings.h')
-rw-r--r--lib/settings.h56
1 files changed, 17 insertions, 39 deletions
diff --git a/lib/settings.h b/lib/settings.h
index c45764a6..ff99d488 100644
--- a/lib/settings.h
+++ b/lib/settings.h
@@ -1,23 +1,10 @@
-/******************************************************************************
- * Copyright (C) 2016 Kitsune Ral <kitsune-ral@users.sf.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// SPDX-FileCopyrightText: 2016 Kitsune Ral <kitsune-ral@users.sf.net>
+// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
+#include "quotient_export.h"
+
#include <QtCore/QSettings>
#include <QtCore/QUrl>
#include <QtCore/QVector>
@@ -26,7 +13,7 @@ class QVariant;
namespace Quotient {
-class Settings : public QSettings {
+class QUOTIENT_API Settings : public QSettings {
Q_OBJECT
public:
/// Add a legacy organisation/application name to migrate settings from
@@ -91,11 +78,10 @@ protected:
QSettings legacySettings { legacyOrganizationName, legacyApplicationName };
};
-class SettingsGroup : public Settings {
+class QUOTIENT_API SettingsGroup : public Settings {
public:
- template <typename... ArgTs>
- explicit SettingsGroup(QString path, ArgTs&&... qsettingsArgs)
- : Settings(std::forward<ArgTs>(qsettingsArgs)...)
+ explicit SettingsGroup(QString path, QObject* parent = nullptr)
+ : Settings(parent)
, groupPath(std::move(path))
{}
@@ -120,7 +106,7 @@ private:
QString groupPath;
};
-#define QTNT_DECLARE_SETTING(type, propname, setter) \
+#define QUO_DECLARE_SETTING(type, propname, setter) \
Q_PROPERTY(type propname READ propname WRITE setter) \
public: \
type propname() const; \
@@ -128,7 +114,7 @@ public: \
\
private:
-#define QTNT_DEFINE_SETTING(classname, type, propname, qsettingname, \
+#define QUO_DEFINE_SETTING(classname, type, propname, qsettingname, \
defaultValue, setter) \
type classname::propname() const \
{ \
@@ -140,21 +126,17 @@ private:
setValue(QStringLiteral(qsettingname), std::move(newValue)); \
}
-class AccountSettings : public SettingsGroup {
+class QUOTIENT_API AccountSettings : public SettingsGroup {
Q_OBJECT
Q_PROPERTY(QString userId READ userId CONSTANT)
- 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)
+ QUO_DECLARE_SETTING(QString, deviceId, setDeviceId)
+ QUO_DECLARE_SETTING(QString, deviceName, setDeviceName)
+ QUO_DECLARE_SETTING(bool, keepLoggedIn, setKeepLoggedIn)
Q_PROPERTY(QByteArray encryptionAccountPickle READ encryptionAccountPickle
WRITE setEncryptionAccountPickle)
public:
- template <typename... ArgTs>
- explicit AccountSettings(const QString& accountId, ArgTs&&... qsettingsArgs)
- : SettingsGroup("Accounts/" + accountId,
- std::forward<ArgTs>(qsettingsArgs)...)
+ explicit AccountSettings(const QString& accountId, QObject* parent = nullptr)
+ : SettingsGroup("Accounts/" + accountId, parent)
{}
QString userId() const;
@@ -162,11 +144,7 @@ public:
QUrl homeserver() const;
void setHomeserver(const QUrl& url);
- /** \deprecated \sa setToken */
- QString accessToken() const;
- /** \deprecated Storing accessToken in QSettings is unsafe,
- * see quotient-im/Quaternion#181 */
- void setAccessToken(const QString& accessToken);
+ Q_DECL_DEPRECATED_X("Access tokens are not stored in QSettings any more")
Q_INVOKABLE void clearAccessToken();
QByteArray encryptionAccountPickle();