feather/src/utils/config.h

144 lines
2.8 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.
2021-06-27 12:51:15 +00:00
#ifndef FEATHER_CONFIG_H
#define FEATHER_CONFIG_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
{
2021-05-26 13:14:53 +00:00
// General
2021-05-18 15:59:18 +00:00
firstRun,
warnOnStagenet,
warnOnTestnet,
warnOnAlpha,
2021-05-18 15:59:18 +00:00
homeWidget,
donateBeg,
2021-05-18 15:59:18 +00:00
showHistorySyncNotice,
geometry,
windowState,
GUI_HistoryViewState,
2021-05-26 13:14:53 +00:00
// Wallets
2021-05-18 15:59:18 +00:00
walletDirectory, // Directory where wallet files are stored
autoOpenWalletPath,
2021-05-18 15:59:18 +00:00
recentlyOpenedWallets,
2021-05-26 13:14:53 +00:00
// Nodes
nodes,
nodeSource,
useOnionNodes,
2021-05-18 15:59:18 +00:00
2021-05-26 13:14:53 +00:00
// Tabs
2020-12-30 04:45:00 +00:00
showTabHome,
showTabCoins,
2020-12-12 01:49:33 +00:00
showTabExchange,
showTabCalc,
showTabXMRig,
2021-05-23 14:58:18 +00:00
showSearchbar,
2021-05-18 15:59:18 +00:00
2021-05-26 13:14:53 +00:00
// Mining
2021-10-12 12:45:06 +00:00
miningMode,
2021-05-18 15:59:18 +00:00
xmrigPath,
2021-10-12 12:45:06 +00:00
xmrigElevated,
xmrigThreads,
2021-05-18 15:59:18 +00:00
xmrigPool,
2021-10-12 12:45:06 +00:00
xmrigNetworkTLS,
xmrigNetworkTor,
2021-07-07 17:11:12 +00:00
pools,
2021-05-18 15:59:18 +00:00
2021-05-26 13:14:53 +00:00
// Settings
2021-05-18 15:59:18 +00:00
preferredFiatCurrency,
skin,
2021-03-12 18:26:48 +00:00
amountPrecision,
2021-03-14 21:12:02 +00:00
dateFormat,
2021-03-16 03:17:01 +00:00
timeFormat,
2021-05-22 14:12:39 +00:00
balanceDisplay,
2021-05-18 15:59:18 +00:00
2021-05-02 18:22:38 +00:00
multiBroadcast,
2021-05-18 15:59:18 +00:00
warnOnExternalLink,
hideBalance,
blockExplorer,
redditFrontend,
localMoneroFrontend,
2021-05-26 13:14:53 +00:00
fiatSymbols,
cryptoSymbols,
// Tor
2021-05-02 18:22:38 +00:00
torPrivacyLevel,
socks5Host,
socks5Port,
socks5User,
socks5Pass,
useLocalTor, // Prevents Feather from starting bundled Tor daemon
2021-05-24 15:20:19 +00:00
initSyncThreshold
2021-05-02 18:22:38 +00:00
};
enum PrivacyLevel {
allTorExceptNode = 0,
allTorExceptInitSync,
allTor
};
2021-05-22 14:12:39 +00:00
enum BalanceDisplay {
totalBalance = 0,
spendablePlusUnconfirmed,
spendable
};
2021-10-12 12:45:06 +00:00
enum MiningMode {
Pool = 0,
Solo
};
~Config() override;
QVariant get(ConfigKey key);
QString getFileName();
void set(ConfigKey key, const QVariant& value);
void remove(ConfigKey key);
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();
}
2021-06-27 12:51:15 +00:00
#endif //FEATHER_CONFIG_H