-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As described in #781 Roughly: - Turn Connection into a type that only exists in an initiated state (from the API user's perspective, at least) - To do this, pull connection setup, etc. out into a new PendingConnection type - Add easy-to-use account login and restoration functions to AccountRegistry - Make connections do the expected things (cache, sync loop, etc.) by default
- Loading branch information
1 parent
3f39d03
commit d80de5a
Showing
16 changed files
with
709 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-FileCopyrightText: 2024 Tobias Fella <[email protected]> | ||
// SPDX-License-Identifier: LGPL-2.0-or-later | ||
|
||
#include "config.h" | ||
|
||
#include <QSettings> | ||
|
||
class QSettingsConfig : public Config | ||
{ | ||
//TODO this backend currently ignores the type and stores everything in the same backend | ||
QString load(const QString& group, const QString& childGroup, const QString& key, Type type) override | ||
{ | ||
settings.beginGroup(group); | ||
settings.beginGroup(childGroup); | ||
auto value = settings.value(key).toString(); | ||
settings.endGroup(); | ||
settings.endGroup(); | ||
return value; | ||
} | ||
|
||
void store(const QString& group, const QString& childGroup, const QString& key, const QString& value, Type type) override | ||
{ | ||
settings.beginGroup(group); | ||
settings.beginGroup(childGroup); | ||
settings.setValue(key, value); | ||
settings.endGroup(); | ||
settings.endGroup(); | ||
settings.sync(); | ||
} | ||
|
||
QStringList childGroups(const QString& group, Type type) override | ||
{ | ||
settings.beginGroup(group); | ||
auto childGroups = settings.childGroups(); | ||
settings.endGroup(); | ||
return childGroups; | ||
} | ||
|
||
QSettings settings; | ||
}; | ||
|
||
Config* Config::s_instance = nullptr; | ||
|
||
Config* Config::instance() | ||
{ | ||
if (!s_instance) { | ||
s_instance = new QSettingsConfig(); | ||
} | ||
return s_instance; | ||
} | ||
|
||
void Config::setInstance(Config* config) | ||
{ | ||
s_instance = config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-FileCopyrightText: 2024 Tobias Fella <[email protected]> | ||
// SPDX-License-Identifier: LGPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <QString> | ||
|
||
class Config | ||
{ | ||
public: | ||
enum Type | ||
{ | ||
Settings, | ||
Data, | ||
}; | ||
virtual QString load(const QString& group, const QString& childGroup, const QString& key, Type type) = 0; | ||
virtual void store(const QString& group, const QString& childGroup, const QString& key, const QString& value, Type type) = 0; | ||
virtual QStringList childGroups(const QString& group, Type type) = 0; | ||
|
||
static Config* instance(); | ||
static void setInstance(Config* config); | ||
|
||
private: | ||
static Config* s_instance; | ||
}; |
Oops, something went wrong.