dash/src/qt/appearancewidget.cpp

163 lines
5.9 KiB
C++
Raw Normal View History

// Copyright (c) 2020-2021 The Dash Core developers
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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)
#include <config/bitcoin-config.h>
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-07-26 13:19:11 +02:00
#endif
#include <qt/forms/ui_appearancewidget.h>
#include <qt/appearancewidget.h>
#include <qt/optionsmodel.h>
merge bitcoin#14555: Move util files to directory (script modified to account for Dash backports, doesn't account for rebasing) ------------- BEGIN SCRIPT --------------- mkdir -p src/util git mv src/util.h src/util/system.h git mv src/util.cpp src/util/system.cpp git mv src/utilmemory.h src/util/memory.h git mv src/utilmoneystr.h src/util/moneystr.h git mv src/utilmoneystr.cpp src/util/moneystr.cpp git mv src/utilstrencodings.h src/util/strencodings.h git mv src/utilstrencodings.cpp src/util/strencodings.cpp git mv src/utiltime.h src/util/time.h git mv src/utiltime.cpp src/util/time.cpp git mv src/utilasmap.h src/util/asmap.h git mv src/utilasmap.cpp src/util/asmap.cpp git mv src/utilstring.h src/util/string.h git mv src/utilstring.cpp src/util/string.cpp gsed -i 's/<util\.h>/<util\/system\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') gsed -i 's/<utilmemory\.h>/<util\/memory\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') gsed -i 's/<utilmoneystr\.h>/<util\/moneystr\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') gsed -i 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') gsed -i 's/<utiltime\.h>/<util\/time\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') gsed -i 's/<utilasmap\.h>/<util\/asmap\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') gsed -i 's/<utilstring\.h>/<util\/string\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') gsed -i 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h gsed -i 's/BITCOIN_UTILMEMORY_H/BITCOIN_UTIL_MEMORY_H/g' src/util/memory.h gsed -i 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h gsed -i 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h gsed -i 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h gsed -i 's/BITCOIN_UTILASMAP_H/BITCOIN_UTIL_ASMAP_H/g' src/util/asmap.h gsed -i 's/BITCOIN_UTILSTRING_H/BITCOIN_UTIL_STRING_H/g' src/util/string.h gsed -i 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am gsed -i 's/utilmemory\.\(h\|cpp\)/util\/memory\.\1/g' src/Makefile.am gsed -i 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am gsed -i 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am gsed -i 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am gsed -i 's/utilasmap\.\(h\|cpp\)/util\/asmap\.\1/g' src/Makefile.am gsed -i 's/utilstring\.\(h\|cpp\)/util\/string\.\1/g' src/Makefile.am gsed -i 's/-> util ->/-> util\/system ->/' test/lint/lint-circular-dependencies.sh gsed -i 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-format-strings.py test/lint/lint-locale-dependence.sh gsed -i 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh gsed -i 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh ------------- END SCRIPT ---------------
2021-06-27 08:33:13 +02:00
#include <util/system.h>
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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()}
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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);
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); });
qt: Fix font size and scaling issues (#3734) * qt: Make sure font size in MasternodeList gets scaled as expected * qt: Make sure font size in ShutdownWindow gets scaled as expected * qt: Drop obsolete application font updates * qt: Scale QMenu and QMessageBox globally To make sure non-custom context menus + QMessageBox instances createy by static calls like QMessageBox::critical are scaled also. * qt: Avoid redundant scaling for tooltips and menus * qt: Only update widget's font if required * qt: Merge GUIUtil::mapFontSizeUpdates into GUIUtil::mapNormalFontUpdates * qt: Remove obsolete setFixedPitchFont call * qt: Use setFixedPitchFont in SendCoinsEntry * qt: Scale font size in increments of 0.25 * qt: Properly scale network traffic stats depending on font metrics * qt: Update min/max width of OptionsDialog depending on buttons width * qt: Emit a signal whenever any attribute of AppearanceWidget changed * qt: Update OptionsDialog width if the appearance changed * qt: Calculate the initial wide right after the window showed up Make sure the visibility state of the widgets is correct before width calculations. * qt: Call parent class showEvent + override it explicit Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * qt: Let OptionsDialog emit a signal if appearance gets changed * qt: Resize main toolbar depending on visible buttons / font attributes * qt: Reset max width after it has been set to still allow window resizing * qt: Properly update the weight of widgets with default font attributes * qt: Handle updates to the font attributes * qt: Use resize() instead of setMaximumWidth() Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> * qt: Call GUIUtil::updateFonts in ModalOverlay constructor * qt: Make sure default fonts are stored properly for the related widget * qt: Ignore some low level classes in GUIUtil::updateFont * rpc: Remove obsolete `.arg()` call * qt: Drop fixedPitchFont * qt: Avoid redundant font updates. Let GUIUtil::updateFont handle them * qt: Scale recent transactions on OverviewPage They were scaled by font inheritance before * qt: Ignore QListView in GUIUtil::updateFonts Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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(); });
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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);
// Force loading the theme
if (model) {
GUIUtil::loadTheme(true);
}
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-07-26 13:19:11 +02:00
}
}
void AppearanceWidget::updateFontFamily(int index)
{
GUIUtil::setFontFamily(static_cast<GUIUtil::FontFamily>(ui->fontFamily->itemData(index).toInt()));
updateWeightSlider(true);
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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()));
}
void AppearanceWidget::updateWeightSlider(const bool fForce)
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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);
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);
qt: Introduce appearance tab and setup dialog (#3568) * qt: Add "Appearance Tab" to OptionsDialog and move "Theme" into it * qt: Add "Font scale" settings to Appearance Tab of OptionsDialog Allows to scale the font in the same way like with -font-scale. * qt: Add font weight settings to Appearance tab of OptionsDialog Allows to set the weight for normal and bold text * qt: Add font family setting to Appearance tab of OptionsDialog Allows to choose between system default font or montserrat * qt: GUIUtil - Maintain a map with supported weights for all fonts. * qt: Introduce AppearanceWidget A widget which just wraps all appearance related settings. Also replaces Appearance settings in OptionsDialog with the introduced widget. * qt: Introduce initial appearance setup dialog This will pop up the first time the user starts the DashCore version with the new UI changes. * qt: Load font related settings in GUIUtil::loadFonts * qt: Make osDefaultFont global in GUIUtil to fix getFont() Before getFont(FontFamily, ...) wasn't always able to return the correct font without the requested font family beeing set as application font upfront. * qt: Improve supported weight helpers Add conversion helpers. and let all of them depend on the currently selected font. * qt: Default weights based on supported if not all weights are supported For SystemDefault only because Montserrat has all supported weights. * qt/test: Fix GUI tests * Store normal/bold font GUI settings as "pure" (not "supported") values * Rename supportedWeighti(To/From)Arg to supportedWeight(To/From)Index to better match the logic and avoid confusion with weight(To/From)Arg functions Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2020-07-26 13:19:11 +02:00
}
}