1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#include "settings.h"
#include <QtCore/QUrl>
#include <QtCore/QDebug>
using namespace QMatrixClient;
void Settings::setValue(const QString& key, const QVariant& value)
{
// qCDebug() << "Setting" << key << "to" << value;
QSettings::setValue(key, value);
}
QVariant Settings::value(const QString& key, const QVariant& defaultValue) const
{
return QSettings::value(key, defaultValue);
}
void SettingsGroup::setValue(const QString& key, const QVariant& value)
{
Settings::setValue(groupPath + "/" + key, value);
}
bool SettingsGroup::contains(const QString& key) const
{
return Settings::contains(groupPath + "/" + key);
}
QVariant SettingsGroup::value(const QString& key, const QVariant& defaultValue) const
{
return Settings::value(groupPath + "/" + key, defaultValue);
}
QString SettingsGroup::group() const
{
return groupPath;
}
QStringList SettingsGroup::childGroups() const
{
const_cast<SettingsGroup*>(this)->beginGroup(groupPath);
QStringList l { Settings::childGroups() };
const_cast<SettingsGroup*>(this)->endGroup();
return l;
}
void SettingsGroup::remove(const QString& key)
{
QString fullKey { groupPath };
if (!key.isEmpty())
fullKey += "/" + key;
Settings::remove(fullKey);
}
bool AccountSettings::keepLoggedIn() const
{
return value("keep_logged_in", false).toBool();
}
void AccountSettings::setKeepLoggedIn(bool newSetting)
{
setValue("keep_logged_in", newSetting);
}
QUrl AccountSettings::homeserver() const
{
return QUrl::fromUserInput(value("homeserver").toString());
}
void AccountSettings::setHomeserver(const QUrl& url)
{
setValue("homeserver", url.toString());
}
QString AccountSettings::userId() const
{
return group().section('/', -1);
}
QString AccountSettings::deviceId() const
{
return value("device_id").toString();
}
void AccountSettings::setDeviceId(const QString& deviceId)
{
setValue("device_id", deviceId);
}
QString AccountSettings::deviceName() const
{
return value("device_name").toString();
}
void AccountSettings::setDeviceName(const QString& deviceName)
{
setValue("device_name", deviceName);
}
QString AccountSettings::accessToken() const
{
return value("access_token").toString();
}
void AccountSettings::setAccessToken(const QString& accessToken)
{
setValue("access_token", accessToken);
}
void AccountSettings::clearAccessToken()
{
remove("access_token");
}
|