2021-04-20 21:33:02 +02:00
|
|
|
// Copyright (c) 2020-2021 The Dash Core developers
|
2020-07-26 13:19:11 +02:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#if defined(HAVE_CONFIG_H)
|
2022-08-02 18:34:58 +02:00
|
|
|
#include <config/bitcoin-config.h>
|
2020-07-26 13:19:11 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <qt/forms/ui_appearancewidget.h>
|
|
|
|
|
|
|
|
#include <qt/appearancewidget.h>
|
|
|
|
#include <qt/optionsmodel.h>
|
|
|
|
|
2021-06-27 08:33:13 +02:00
|
|
|
#include <util/system.h>
|
2020-07-26 13:19:11 +02:00
|
|
|
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QDataWidgetMapper>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QSlider>
|
|
|
|
|
|
|
|
AppearanceWidget::AppearanceWidget(QWidget* parent) :
|
|
|
|
QWidget(parent),
|
fix: resolve numerous compilation warnings under -Wall (#4599)
* fix: compilation warnings
./validation.h:266:13: warning: ‘bool AcceptToMemoryPoolWithTime(const CChainParams&, CTxMemPool&, CValidationState&, const CTransactionRef&, bool*, int64_t, bool, CAmount, bool)’ declared ‘static’ but never defined [-Wunused-function]
static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPool& pool, CValidationState &state, const CTransactionRef &tx,
^~~~~~~~~~~~~~~~~~~~~~~~~~
* fix: compilation warnings
./coinjoin/client.h: In constructor ‘CCoinJoinClientManager::CCoinJoinClientManager(CWallet&)’:
./coinjoin/client.h:199:10: warning: ‘CCoinJoinClientManager::fCreateAutoBackups’ will be initialized after [-Wreorder]
bool fCreateAutoBackups; // builtin support for automatic backups
^~~~~~~~~~~~~~~~~~
./coinjoin/client.h:187:14: warning: ‘CWallet& CCoinJoinClientManager::mixingWallet’ [-Wreorder]
CWallet& mixingWallet;
^~~~~~~~~~~~
./coinjoin/client.h:205:14: warning: when initialized here [-Wreorder]
explicit CCoinJoinClientManager(CWallet& wallet) :
^~~~~~~~~~~~~~~~~~~~~~
* fix: compilation warnings
interfaces/wallet.cpp: In constructor ‘interfaces::{anonymous}::WalletImpl::WalletImpl(const std::shared_ptr<CWallet>&)’:
interfaces/wallet.cpp:594:30: warning: ‘interfaces::{anonymous}::WalletImpl::m_wallet’ will be initialized after [-Wreorder]
std::shared_ptr<CWallet> m_wallet;
^~~~~~~~
interfaces/wallet.cpp:191:18: warning: ‘interfaces::{anonymous}::CoinJoinImpl interfaces::{anonymous}::WalletImpl::m_coinjoin’ [-Wreorder]
CoinJoinImpl m_coinjoin;
^~~~~~~~~~
interfaces/wallet.cpp:193:14: warning: when initialized here [-Wreorder]
explicit WalletImpl(const std::shared_ptr<CWallet>& wallet) : m_wallet(wallet), m_coinjoin(wallet) {}
^~~~~~~~~~
* fix: compilation warnings
validation.cpp:165:13: warning: ‘void CheckBlockIndex(const Consensus::Params&)’ declared ‘static’ but never defined [-Wunused-function]
static void CheckBlockIndex(const Consensus::Params& consensusParams);
^~~~~~~~~~~~~~~
* fix: compilation warnings
bls/bls_worker.cpp: In constructor ‘ContributionVerifier::ContributionVerifier(CBLSId, const std::vector<std::shared_ptr<std::vector<CBLSPublicKey> > >&, const BLSSecretKeyVector&, size_t, bool, bool, ctpl::thread_pool&, std::function<void(const std::vector<bool>&)>)’:
bls/bls_worker.cpp:425:51: warning: ‘ContributionVerifier::doneCallback’ will be initialized after [-Wreorder]
std::function<void(const std::vector<bool>&)> doneCallback;
^~~~~~~~~~~~
bls/bls_worker.cpp:420:12: warning: ‘size_t ContributionVerifier::batchCount’ [-Wreorder]
size_t batchCount;
^~~~~~~~~~
bls/bls_worker.cpp:427:5: warning: when initialized here [-Wreorder]
ContributionVerifier(CBLSId _forId, const std::vector<BLSVerificationVectorPtr>& _vvecs,
^~~~~~~~~~~~~~~~~~~~
* fix: compilation warnings
bls/bls_worker.cpp:342:10: warning: ‘VectorAggregator<CBLSPublicKey>::parallel’ will be initialized after [-Wreorder]
bool parallel;
^~~~~~~~
bls/bls_worker.cpp:340:12: warning: ‘size_t VectorAggregator<CBLSPublicKey>::start’ [-Wreorder]
size_t start;
^~~~~
bls/bls_worker.cpp:350:5: warning: when initialized here [-Wreorder]
VectorAggregator(const VectorVectorType& _vecs,
^~~~~~~~~~~~~~~~
bls/bls_worker.cpp:343:24: warning: ‘VectorAggregator<CBLSPublicKey>::workerPool’ will be initialized after [-Wreorder]
ctpl::thread_pool& workerPool;
^~~~~~~~~~
bls/bls_worker.cpp:337:18: warning: ‘VectorAggregator<CBLSPublicKey>::DoneCallback VectorAggregator<CBLSPublicKey>::doneCallback’ [-Wreorder]
DoneCallback doneCallback;
^~~~~~~~~~~~
bls/bls_worker.cpp:350:5: warning: when initialized here [-Wreorder]
VectorAggregator(const VectorVectorType& _vecs,
^~~~~~~~~~~~~~~~
* fix: compilation warnings
bls/bls_worker.cpp:494:235: required from here
bls/bls_worker.cpp:136:24: warning: ‘Aggregator<CBLSSecretKey>::workerPool’ will be initialized after [-Wreorder]
ctpl::thread_pool& workerPool;
^~~~~~~~~~
bls/bls_worker.cpp:135:10: warning: ‘bool Aggregator<CBLSSecretKey>::parallel’ [-Wreorder]
bool parallel;
^~~~~~~~
bls/bls_worker.cpp:152:5: warning: when initialized here [-Wreorder]
Aggregator(const std::vector<TP>& _inputVec,
^~~~~~~~~~
* fix: compilation warnings
bench/string_cast.cpp: In lambda function:
bench/string_cast.cpp:22:13: warning: statement has no effect [-Wunused-value]
atoi("1");
~~~~^~~~~
* fix: compilation warnings
./llmq/dkgsessionhandler.h: In constructor ‘llmq::CDKGPendingMessages::CDKGPendingMessages(size_t, int)’:
./llmq/dkgsessionhandler.h:48:12: warning: ‘llmq::CDKGPendingMessages::maxMessagesPerNode’ will be initialized after [-Wreorder]
size_t maxMessagesPerNode GUARDED_BY(cs);
^~~~~~~~~~~~~~~~~~
./llmq/dkgsessionhandler.h:47:15: warning: ‘const int llmq::CDKGPendingMessages::invType’ [-Wreorder]
const int invType;
^~~~~~~
llmq/dkgsessionhandler.cpp:23:1: warning: when initialized here [-Wreorder]
CDKGPendingMessages::CDKGPendingMessages(size_t _maxMessagesPerNode, int _invType) :
^~~~~~~~~~~~~~~~~~~
* fix: compilation warnings
Not sure this one is correct, but I believe so. Seems like the `!= 0` is completely not needed
rpc/masternode.cpp: In function ‘UniValue masternode_payments(const JSONRPCRequest&)’:
rpc/masternode.cpp:442:31: warning: suggest parentheses around comparison in operand of ‘!=’ [-Wparentheses]
while (vecPayments.size() < std::abs(nCount) != 0 && pindex != nullptr) {
~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
* fix: compilation warnings
test/cachemultimap_tests.cpp:14:13: warning: ‘void cachemultimap_tests::DumpMap(const CacheMultiMap<int, int>&)’ defined but not used [-Wunused-function]
static void DumpMap(const CacheMultiMap<int,int>& cmmap)
^~~~~~~
* fix: compilation warnings
In file included from qt/appearancewidget.cpp:11:
./qt/appearancewidget.h: In constructor ‘AppearanceWidget::AppearanceWidget(QWidget*)’:
./qt/appearancewidget.h:52:25: warning: ‘AppearanceWidget::prevFontFamily’ will be initialized after [-Wreorder]
GUIUtil::FontFamily prevFontFamily;
^~~~~~~~~~~~~~
./qt/appearancewidget.h:51:9: warning: ‘int AppearanceWidget::prevScale’ [-Wreorder]
int prevScale;
^~~~~~~~~
qt/appearancewidget.cpp:21:1: warning: when initialized here [-Wreorder]
AppearanceWidget::AppearanceWidget(QWidget* parent) :
^~~~~~~~~~~~~~~~
* fix: compilation warnings
In file included from qt/bitcoingui.cpp:6:
./qt/bitcoingui.h: In constructor ‘BitcoinGUI::BitcoinGUI(interfaces::Node&, const NetworkStyle*, QWidget*)’:
./qt/bitcoingui.h:212:31: warning: ‘BitcoinGUI::m_network_style’ will be initialized after [-Wreorder]
const NetworkStyle* const m_network_style;
^~~~~~~~~~~~~~~
./qt/bitcoingui.h:172:34: warning: ‘const std::unique_ptr<QMenu> BitcoinGUI::trayIconMenu’ [-Wreorder]
const std::unique_ptr<QMenu> trayIconMenu;
^~~~~~~~~~~~
qt/bitcoingui.cpp:81:1: warning: when initialized here [-Wreorder]
BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, QWidget* parent) :
^~~~~~~~~~
* fix: compilation warnings
In file included from qt/masternodelist.cpp:1:
./qt/masternodelist.h: In constructor ‘MasternodeList::MasternodeList(QWidget*)’:
./qt/masternodelist.h:66:18: warning: ‘MasternodeList::walletModel’ will be initialized after [-Wreorder]
WalletModel* walletModel;
^~~~~~~~~~~
./qt/masternodelist.h:61:10: warning: ‘bool MasternodeList::fFilterUpdatedDIP3’ [-Wreorder]
bool fFilterUpdatedDIP3;
^~~~~~~~~~~~~~~~~~
qt/masternodelist.cpp:45:1: warning: when initialized here [-Wreorder]
MasternodeList::MasternodeList(QWidget* parent) :
^~~~~~~~~~~~~~
In file included from qt/masternodelist.cpp:1:
./qt/masternodelist.h:61:10: warning: ‘MasternodeList::fFilterUpdatedDIP3’ will be initialized after [-Wreorder]
bool fFilterUpdatedDIP3;
^~~~~~~~~~~~~~~~~~
./qt/masternodelist.h:59:13: warning: ‘int64_t MasternodeList::nTimeFilterUpdatedDIP3’ [-Wreorder]
int64_t nTimeFilterUpdatedDIP3;
^~~~~~~~~~~~~~~~~~~~~~
qt/masternodelist.cpp:45:1: warning: when initialized here [-Wreorder]
MasternodeList::MasternodeList(QWidget* parent) :
^~~~~~~~~~~~~~
* fix: compilation warnings
In file included from qt/paymentserver.cpp:10:
./qt/paymentserver.h: In constructor ‘PaymentServer::PaymentServer(QObject*, bool)’:
./qt/paymentserver.h:156:28: warning: ‘PaymentServer::netManager’ will be initialized after [-Wreorder]
QNetworkAccessManager* netManager; // Used to fetch payment requests
^~~~~~~~~~
./qt/paymentserver.h:147:19: warning: ‘OptionsModel* PaymentServer::optionsModel’ [-Wreorder]
OptionsModel *optionsModel;
^~~~~~~~~~~~
qt/paymentserver.cpp:197:1: warning: when initialized here [-Wreorder]
PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) :
^~~~~~~~~~~~~
2021-12-01 20:59:34 +01:00
|
|
|
ui{new Ui::AppearanceWidget()}
|
2020-07-26 13:19:11 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
for (const QString& entry : GUIUtil::listThemes()) {
|
|
|
|
ui->theme->addItem(entry, QVariant(entry));
|
|
|
|
}
|
|
|
|
|
|
|
|
GUIUtil::FontFamily fontSystem = GUIUtil::FontFamily::SystemDefault;
|
|
|
|
GUIUtil::FontFamily fontMontserrat = GUIUtil::FontFamily::Montserrat;
|
|
|
|
|
|
|
|
ui->fontFamily->addItem(GUIUtil::fontFamilyToString(fontSystem), QVariant(static_cast<int>(fontSystem)));
|
|
|
|
ui->fontFamily->addItem(GUIUtil::fontFamilyToString(fontMontserrat), QVariant(static_cast<int>(fontMontserrat)));
|
|
|
|
|
|
|
|
updateWeightSlider();
|
|
|
|
|
|
|
|
mapper = new QDataWidgetMapper(this);
|
|
|
|
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
|
|
|
|
mapper->setOrientation(Qt::Vertical);
|
|
|
|
|
2021-08-17 17:55:26 +02:00
|
|
|
connect(ui->theme, &QComboBox::currentTextChanged, this, &AppearanceWidget::updateTheme);
|
|
|
|
connect(ui->fontFamily, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AppearanceWidget::updateFontFamily);
|
|
|
|
connect(ui->fontScaleSlider, &QSlider::valueChanged, this, &AppearanceWidget::updateFontScale);
|
|
|
|
connect(ui->fontWeightNormalSlider, &QSlider::valueChanged, [this](auto nValue) { updateFontWeightNormal(nValue); });
|
|
|
|
connect(ui->fontWeightBoldSlider, &QSlider::valueChanged, [this](auto nValue) { updateFontWeightBold(nValue); });
|
2020-09-29 01:15:20 +02:00
|
|
|
|
|
|
|
connect(ui->theme, &QComboBox::currentTextChanged, [=]() { Q_EMIT appearanceChanged(); });
|
|
|
|
connect(ui->fontFamily, &QComboBox::currentTextChanged, [=]() { Q_EMIT appearanceChanged(); });
|
|
|
|
connect(ui->fontScaleSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); });
|
|
|
|
connect(ui->fontWeightNormalSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); });
|
|
|
|
connect(ui->fontWeightBoldSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); });
|
2020-07-26 13:19:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
AppearanceWidget::~AppearanceWidget()
|
|
|
|
{
|
|
|
|
if (fAcceptChanges) {
|
|
|
|
mapper->submit();
|
|
|
|
} else {
|
|
|
|
if (prevTheme != GUIUtil::getActiveTheme()) {
|
|
|
|
updateTheme(prevTheme);
|
|
|
|
}
|
|
|
|
if (prevFontFamily != GUIUtil::getFontFamily()) {
|
|
|
|
GUIUtil::setFontFamily(prevFontFamily);
|
|
|
|
}
|
|
|
|
if (prevScale != GUIUtil::getFontScale()) {
|
|
|
|
GUIUtil::setFontScale(prevScale);
|
|
|
|
}
|
|
|
|
if (prevWeightNormal != GUIUtil::getFontWeightNormal()) {
|
|
|
|
GUIUtil::setFontWeightNormal(prevWeightNormal);
|
|
|
|
}
|
|
|
|
if (prevWeightBold != GUIUtil::getFontWeightBold()) {
|
|
|
|
GUIUtil::setFontWeightBold(prevWeightBold);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppearanceWidget::setModel(OptionsModel* _model)
|
|
|
|
{
|
|
|
|
this->model = _model;
|
|
|
|
|
|
|
|
if (_model) {
|
|
|
|
mapper->setModel(_model);
|
|
|
|
mapper->addMapping(ui->theme, OptionsModel::Theme);
|
|
|
|
mapper->addMapping(ui->fontFamily, OptionsModel::FontFamily);
|
|
|
|
mapper->addMapping(ui->fontScaleSlider, OptionsModel::FontScale);
|
|
|
|
mapper->addMapping(ui->fontWeightNormalSlider, OptionsModel::FontWeightNormal);
|
|
|
|
mapper->addMapping(ui->fontWeightBoldSlider, OptionsModel::FontWeightBold);
|
|
|
|
mapper->toFirst();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppearanceWidget::accept()
|
|
|
|
{
|
|
|
|
fAcceptChanges = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppearanceWidget::updateTheme(const QString& theme)
|
|
|
|
{
|
|
|
|
QString newValue = theme.isEmpty() ? ui->theme->currentData().toString() : theme;
|
|
|
|
if (GUIUtil::getActiveTheme() != newValue) {
|
|
|
|
QSettings().setValue("theme", newValue);
|
2020-07-27 09:32:48 +02:00
|
|
|
// Force loading the theme
|
2021-03-19 16:02:25 +01:00
|
|
|
if (model) {
|
2021-04-10 22:31:58 +02:00
|
|
|
GUIUtil::loadTheme(true);
|
2021-03-19 16:02:25 +01:00
|
|
|
}
|
2020-07-26 13:19:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppearanceWidget::updateFontFamily(int index)
|
|
|
|
{
|
|
|
|
GUIUtil::setFontFamily(static_cast<GUIUtil::FontFamily>(ui->fontFamily->itemData(index).toInt()));
|
2021-05-06 19:15:47 +02:00
|
|
|
updateWeightSlider(true);
|
2020-07-26 13:19:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppearanceWidget::updateFontScale(int nScale)
|
|
|
|
{
|
|
|
|
GUIUtil::setFontScale(nScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppearanceWidget::updateFontWeightNormal(int nValue, bool fForce)
|
|
|
|
{
|
|
|
|
int nSliderValue = nValue;
|
|
|
|
if (nValue > ui->fontWeightBoldSlider->value() && !fForce) {
|
|
|
|
nSliderValue = ui->fontWeightBoldSlider->value();
|
|
|
|
}
|
|
|
|
const QSignalBlocker blocker(ui->fontWeightNormalSlider);
|
|
|
|
ui->fontWeightNormalSlider->setValue(nSliderValue);
|
|
|
|
GUIUtil::setFontWeightNormal(GUIUtil::supportedWeightFromIndex(ui->fontWeightNormalSlider->value()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppearanceWidget::updateFontWeightBold(int nValue, bool fForce)
|
|
|
|
{
|
|
|
|
int nSliderValue = nValue;
|
|
|
|
if (nValue < ui->fontWeightNormalSlider->value() && !fForce) {
|
|
|
|
nSliderValue = ui->fontWeightNormalSlider->value();
|
|
|
|
}
|
|
|
|
const QSignalBlocker blocker(ui->fontWeightBoldSlider);
|
|
|
|
ui->fontWeightBoldSlider->setValue(nSliderValue);
|
|
|
|
GUIUtil::setFontWeightBold(GUIUtil::supportedWeightFromIndex(ui->fontWeightBoldSlider->value()));
|
|
|
|
}
|
|
|
|
|
2021-05-06 19:15:47 +02:00
|
|
|
void AppearanceWidget::updateWeightSlider(const bool fForce)
|
2020-07-26 13:19:11 +02:00
|
|
|
{
|
|
|
|
int nMaximum = GUIUtil::getSupportedWeights().size() - 1;
|
|
|
|
|
|
|
|
ui->fontWeightNormalSlider->setMinimum(0);
|
|
|
|
ui->fontWeightNormalSlider->setMaximum(nMaximum);
|
|
|
|
|
|
|
|
ui->fontWeightBoldSlider->setMinimum(0);
|
|
|
|
ui->fontWeightBoldSlider->setMaximum(nMaximum);
|
|
|
|
|
2021-05-06 19:15:47 +02:00
|
|
|
if (fForce || !GUIUtil::isSupportedWeight(prevWeightNormal) || !GUIUtil::isSupportedWeight(prevWeightBold)) {
|
|
|
|
int nIndexNormal = GUIUtil::supportedWeightToIndex(GUIUtil::getSupportedFontWeightNormalDefault());
|
|
|
|
int nIndexBold = GUIUtil::supportedWeightToIndex(GUIUtil::getSupportedFontWeightBoldDefault());
|
|
|
|
assert(nIndexNormal != -1 && nIndexBold != -1);
|
|
|
|
updateFontWeightNormal(nIndexNormal, true);
|
|
|
|
updateFontWeightBold(nIndexBold, true);
|
2020-07-26 13:19:11 +02:00
|
|
|
}
|
|
|
|
}
|