feather/src/utils/config.h

107 lines
2.3 KiB
C
Raw Normal View History

// SPDX-License-Identifier: BSD-3-Clause
// Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
// Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
2020-12-26 19:56:06 +00:00
// Copyright (c) 2020-2021, The Monero Project.
#ifndef FEATHER_SETTINGS_H
#define FEATHER_SETTINGS_H
#include <QObject>
#include <QSettings>
#include <QPointer>
2021-03-12 18:26:48 +00:00
#include <QDir>
class Config : public QObject
{
Q_OBJECT
public:
Q_DISABLE_COPY(Config)
enum ConfigKey
{
warnOnExternalLink,
2021-05-02 18:22:38 +00:00
checkForUpdates,
warnOnStagenet,
warnOnTestnet,
warnOnAlpha,
homeWidget,
donateBeg,
autoOpenWalletPath,
skin,
preferredFiatCurrency,
blockExplorer,
walletDirectory,
walletPath,
xmrigPath,
xmrigPool,
nodes,
websocketEnabled,
nodeSource,
useOnionNodes,
2020-12-30 04:45:00 +00:00
showTabHome,
showTabCoins,
2020-12-12 01:49:33 +00:00
showTabExchange,
showTabCalc,
showTabXMRig,
geometry,
windowState,
2020-11-02 09:37:36 +00:00
firstRun,
2020-12-30 02:48:10 +00:00
hideBalance,
2020-12-30 03:58:17 +00:00
redditFrontend,
2021-03-08 20:03:20 +00:00
showHistorySyncNotice,
GUI_HistoryViewState,
2021-03-12 18:26:48 +00:00
amountPrecision,
2021-03-14 21:12:02 +00:00
portableMode,
dateFormat,
2021-03-16 03:17:01 +00:00
timeFormat,
2021-05-02 18:22:38 +00:00
multiBroadcast,
torPrivacyLevel,
socks5Host,
socks5Port,
socks5User,
socks5Pass,
useLocalTor, // Prevents Feather from starting bundled Tor daemon
networkType,
localMoneroFrontend
};
enum PrivacyLevel {
allTorExceptNode = 0,
allTorExceptInitSync,
allTor
};
~Config() override;
QVariant get(ConfigKey key);
QString getFileName();
void set(ConfigKey key, const QVariant& value);
void sync();
void resetToDefaults();
2021-03-12 18:26:48 +00:00
static QDir defaultConfigDir();
static QDir defaultPortableConfigDir();
static Config* instance();
signals:
2021-05-02 18:22:38 +00:00
void changed(Config::ConfigKey key);
private:
Config(const QString& fileName, QObject* parent = nullptr);
explicit Config(QObject* parent);
void init(const QString& configFileName);
static QPointer<Config> m_instance;
QScopedPointer<QSettings> m_settings;
QHash<QString, QVariant> m_defaults;
};
inline Config* config()
{
return Config::instance();
}
#endif //FEATHER_SETTINGS_H