mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
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
This commit is contained in:
parent
586f166499
commit
cf2da32ffe
@ -218,7 +218,7 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
|
||||
QFont font;
|
||||
if(index.column() == Address)
|
||||
{
|
||||
font = GUIUtil::fixedPitchFont();
|
||||
font = GUIUtil::getFontNormal();
|
||||
}
|
||||
return font;
|
||||
}
|
||||
|
@ -51,6 +51,12 @@ AppearanceWidget::AppearanceWidget(QWidget* parent) :
|
||||
connect(ui->fontScaleSlider, SIGNAL(valueChanged(int)), this, SLOT(updateFontScale(int)));
|
||||
connect(ui->fontWeightNormalSlider, SIGNAL(valueChanged(int)), this, SLOT(updateFontWeightNormal(int)));
|
||||
connect(ui->fontWeightBoldSlider, SIGNAL(valueChanged(int)), this, SLOT(updateFontWeightBold(int)));
|
||||
|
||||
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(); });
|
||||
}
|
||||
|
||||
AppearanceWidget::~AppearanceWidget()
|
||||
|
@ -29,6 +29,9 @@ public:
|
||||
|
||||
void setModel(OptionsModel* model);
|
||||
|
||||
Q_SIGNALS:
|
||||
void appearanceChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
void accept();
|
||||
|
||||
|
@ -466,6 +466,8 @@ void BitcoinGUI::createActions()
|
||||
for (auto button : tabGroup->buttons()) {
|
||||
GUIUtil::setFont({button}, GUIUtil::FontWeight::Normal, 16);
|
||||
}
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
// Give the selected tab button a bolder font.
|
||||
connect(tabGroup, SIGNAL(buttonToggled(QAbstractButton *, bool)), this, SLOT(highlightTabButton(QAbstractButton *, bool)));
|
||||
#endif // ENABLE_WALLET
|
||||
@ -914,6 +916,9 @@ void BitcoinGUI::optionsClicked()
|
||||
|
||||
OptionsDialog dlg(this, enableWallet);
|
||||
dlg.setModel(clientModel->getOptionsModel());
|
||||
connect(&dlg, &OptionsDialog::appearanceChanged, [=]() {
|
||||
updateWidth();
|
||||
});
|
||||
dlg.exec();
|
||||
|
||||
updatePrivateSendVisibility();
|
||||
@ -1000,6 +1005,7 @@ void BitcoinGUI::openClicked()
|
||||
void BitcoinGUI::highlightTabButton(QAbstractButton *button, bool checked)
|
||||
{
|
||||
GUIUtil::setFont({button}, checked ? GUIUtil::FontWeight::Bold : GUIUtil::FontWeight::Normal, 16);
|
||||
GUIUtil::updateFonts();
|
||||
}
|
||||
|
||||
void BitcoinGUI::gotoOverviewPage()
|
||||
@ -1161,6 +1167,26 @@ void BitcoinGUI::updatePrivateSendVisibility()
|
||||
privateSendCoinsMenuAction->setVisible(fEnabled);
|
||||
showPrivateSendHelpAction->setVisible(fEnabled);
|
||||
updateToolBarShortcuts();
|
||||
updateWidth();
|
||||
}
|
||||
|
||||
void BitcoinGUI::updateWidth()
|
||||
{
|
||||
int nWidthWidestButton{0};
|
||||
int nButtonsVisible{0};
|
||||
for (QAbstractButton* button : tabGroup->buttons()) {
|
||||
if (!button->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
QFontMetrics fm(button->font());
|
||||
nWidthWidestButton = std::max<int>(nWidthWidestButton, fm.width(button->text()));
|
||||
++nButtonsVisible;
|
||||
}
|
||||
// Add 30 per button as padding and use minimum 980 which is the minimum required to show all tab's contents
|
||||
// Use nButtonsVisible + 1 <- for the dash logo
|
||||
int nWidth = std::max<int>(980, (nWidthWidestButton + 30) * (nButtonsVisible + 1));
|
||||
setMinimumWidth(nWidth);
|
||||
resize(nWidth, height());
|
||||
}
|
||||
|
||||
void BitcoinGUI::updateToolBarShortcuts()
|
||||
@ -1478,6 +1504,10 @@ void BitcoinGUI::showEvent(QShowEvent *event)
|
||||
openRepairAction->setEnabled(true);
|
||||
aboutAction->setEnabled(true);
|
||||
optionsAction->setEnabled(true);
|
||||
|
||||
if (!event->spontaneous()) {
|
||||
updateWidth();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
|
@ -322,6 +322,8 @@ private Q_SLOTS:
|
||||
void showModalOverlay();
|
||||
|
||||
void updatePrivateSendVisibility();
|
||||
|
||||
void updateWidth();
|
||||
};
|
||||
|
||||
class UnitDisplayStatusBarControl : public QLabel
|
||||
|
@ -139,12 +139,8 @@ static QFont::Weight fontWeightNormal = defaultFontWeightNormal;
|
||||
// Application font weight for bold text. May be overwritten by -font-weight-bold.
|
||||
static QFont::Weight fontWeightBold = defaultFontWeightBold;
|
||||
|
||||
// Contains all widgets and its font attributes (weight, italic) with font changes due to GUIUtil::setFont
|
||||
static std::map<QWidget*, std::pair<FontWeight, bool>> mapNormalFontUpdates;
|
||||
// Contains all widgets where a fixed pitch font has been set with GUIUtil::setFixedPitchFont
|
||||
static std::set<QWidget*> setFixedPitchFontUpdates;
|
||||
// Contains all widgets where a non-default fontsize has been seet with GUIUtil::setFont
|
||||
static std::map<QWidget*, int> mapFontSizeUpdates;
|
||||
// Contains all widgets and its font attributes (weight, italic, size) with font changes due to GUIUtil::setFont
|
||||
static std::map<QWidget*, std::tuple<FontWeight, bool, int>> mapNormalFontUpdates;
|
||||
// Contains a list of supported font weights for all members of GUIUtil::FontFamily
|
||||
static std::map<FontFamily, std::vector<QFont::Weight>> mapSupportedWeights;
|
||||
|
||||
@ -269,25 +265,6 @@ QString dateTimeStr(qint64 nTime)
|
||||
return dateTimeStr(QDateTime::fromTime_t((qint32)nTime));
|
||||
}
|
||||
|
||||
QFont fixedPitchFont()
|
||||
{
|
||||
if (dashThemeActive()) {
|
||||
return getFontNormal();
|
||||
} else {
|
||||
#if QT_VERSION >= 0x50200
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
#else
|
||||
QFont font("Monospace");
|
||||
#if QT_VERSION >= 0x040800
|
||||
font.setStyleHint(QFont::Monospace);
|
||||
#else
|
||||
font.setStyleHint(QFont::TypeWriter);
|
||||
#endif
|
||||
return font;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Just some dummy data to generate an convincing random-looking (but consistent) address
|
||||
static const uint8_t dummydata[] = {0xeb,0x15,0x23,0x1d,0xfc,0xeb,0x60,0x92,0x58,0x86,0xb6,0x7d,0x06,0x52,0x99,0x92,0x59,0x15,0xae,0xb1,0x72,0xc0,0x66,0x47};
|
||||
|
||||
@ -310,7 +287,6 @@ void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent, bool fAllow
|
||||
{
|
||||
parent->setFocusProxy(widget);
|
||||
|
||||
setFixedPitchFont({widget});
|
||||
#if QT_VERSION >= 0x040700
|
||||
// We don't want translators to use own addresses in translations
|
||||
// and this is the only place, where this address is supplied.
|
||||
@ -1426,7 +1402,7 @@ void setFontScale(int nScale)
|
||||
|
||||
double getScaledFontSize(int nSize)
|
||||
{
|
||||
return (nSize * (1 + (fontScale * fontScaleSteps)));
|
||||
return std::round(nSize * (1 + (fontScale * fontScaleSteps)) * 4) / 4.0;
|
||||
}
|
||||
|
||||
bool loadFonts()
|
||||
@ -1574,27 +1550,12 @@ void setApplicationFont()
|
||||
|
||||
void setFont(const std::vector<QWidget*>& vecWidgets, FontWeight weight, int nPointSize, bool fItalic)
|
||||
{
|
||||
QFont font = getFont(weight, fItalic, nPointSize);
|
||||
|
||||
for (auto it : vecWidgets) {
|
||||
auto fontAttributes = std::make_pair(weight, fItalic);
|
||||
auto itw = mapNormalFontUpdates.emplace(std::make_pair(it, fontAttributes));
|
||||
if (!itw.second) itw.first->second = fontAttributes;
|
||||
|
||||
if (nPointSize != -1) {
|
||||
auto its = mapFontSizeUpdates.emplace(std::make_pair(it, nPointSize));
|
||||
if (!its.second) its.first->second = nPointSize;
|
||||
auto fontAttributes = std::make_tuple(weight, fItalic, nPointSize);
|
||||
auto itFontUpdate = mapNormalFontUpdates.emplace(std::make_pair(it, fontAttributes));
|
||||
if (!itFontUpdate.second) {
|
||||
itFontUpdate.first->second = fontAttributes;
|
||||
}
|
||||
|
||||
it->setFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
void setFixedPitchFont(const std::vector<QWidget*>& vecWidgets)
|
||||
{
|
||||
for (auto it : vecWidgets) {
|
||||
setFixedPitchFontUpdates.emplace(it);
|
||||
it->setFont(fixedPitchFont());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1605,75 +1566,100 @@ void updateFonts()
|
||||
return;
|
||||
}
|
||||
|
||||
setApplicationFont();
|
||||
|
||||
auto getKey = [](QWidget* w) -> QString {
|
||||
return w->parent() ? w->parent()->objectName() + w->objectName() : w->objectName();
|
||||
};
|
||||
|
||||
static std::map<QString, int> mapDefaultFontSizes;
|
||||
std::map<QWidget*, QFont> mapWidgetFonts;
|
||||
static std::map<QWidget*, int> mapWidgetDefaultFontSizes;
|
||||
static std::map<QString, int> mapClassDefaultFontSizes;
|
||||
std::map<QWidget*, std::pair<QFont, bool>> mapWidgetFonts;
|
||||
|
||||
for (QWidget* w : qApp->allWidgets()) {
|
||||
std::vector<QString> vecIgnore{
|
||||
"QWidget", "QDialog", "QFrame", "QStackedWidget", "QDesktopWidget", "QDesktopScreenWidget",
|
||||
"QTipLabel", "QMessageBox", "QMenu", "QComboBoxPrivateScroller", "QComboBoxPrivateContainer",
|
||||
"QScrollBar", "QListView", "BitcoinGUI", "WalletView", "WalletFrame"
|
||||
};
|
||||
if (std::find(vecIgnore.begin(), vecIgnore.end(), w->metaObject()->className()) != vecIgnore.end()) {
|
||||
continue;
|
||||
}
|
||||
QFont font = w->font();
|
||||
font.setFamily(qApp->font().family());
|
||||
font.setWeight(getFontWeightNormal());
|
||||
font.setStyleName(qApp->font().styleName());
|
||||
font.setStyle(qApp->font().style());
|
||||
// Set the font size based on the widgets default font size + the font scale
|
||||
QString key = getKey(w);
|
||||
if (!mapDefaultFontSizes.count(key)) {
|
||||
mapDefaultFontSizes.emplace(std::make_pair(key, font.pointSize() > 0 ? font.pointSize() : defaultFontSize));
|
||||
bool fAdded = false;
|
||||
if (!mapWidgetDefaultFontSizes.count(w)) {
|
||||
mapWidgetDefaultFontSizes.emplace(std::make_pair(w, font.pointSize() > 0 ? font.pointSize() : defaultFontSize));
|
||||
fAdded = true;
|
||||
}
|
||||
font.setPointSizeF(getScaledFontSize(mapDefaultFontSizes[key]));
|
||||
mapWidgetFonts.emplace(w, font);
|
||||
font.setPointSizeF(getScaledFontSize(mapWidgetDefaultFontSizes[w]));
|
||||
bool fUpdateRequired = fAdded || (mapNormalFontUpdates.find(w) == mapNormalFontUpdates.end() && font != w->font());
|
||||
mapWidgetFonts.emplace(w, std::make_pair(font, fUpdateRequired));
|
||||
}
|
||||
|
||||
auto itn = mapNormalFontUpdates.begin();
|
||||
while (itn != mapNormalFontUpdates.end()) {
|
||||
if (mapWidgetFonts.count(itn->first)) {
|
||||
mapWidgetFonts[itn->first] = getFont(itn->second.first, itn->second.second, mapDefaultFontSizes[getKey(itn->first)]);
|
||||
auto itw = mapWidgetFonts.find(itn->first);
|
||||
if (itw != mapWidgetFonts.end()) {
|
||||
int nSize = std::get<2>(itn->second);
|
||||
if (nSize == -1) {
|
||||
nSize = mapWidgetDefaultFontSizes[itn->first];
|
||||
}
|
||||
QFont&& font = getFont(std::get<0>(itn->second), std::get<1>(itn->second), nSize);
|
||||
if (itn->first->font() != font) {
|
||||
itw->second.first = font;
|
||||
itw->second.second = true;
|
||||
}
|
||||
++itn;
|
||||
} else {
|
||||
itn = mapNormalFontUpdates.erase(itn);
|
||||
}
|
||||
}
|
||||
auto its = mapFontSizeUpdates.begin();
|
||||
while (its != mapFontSizeUpdates.end()) {
|
||||
if (mapWidgetFonts.count(its->first)) {
|
||||
QFont font = mapWidgetFonts[its->first];
|
||||
font.setPointSizeF(getScaledFontSize(its->second));
|
||||
mapWidgetFonts[its->first] = font;
|
||||
++its;
|
||||
} else {
|
||||
its = mapFontSizeUpdates.erase(its);
|
||||
}
|
||||
}
|
||||
auto itf = setFixedPitchFontUpdates.begin();
|
||||
while (itf != setFixedPitchFontUpdates.end()) {
|
||||
if (mapWidgetFonts.count(*itf)) {
|
||||
QFont font = fixedPitchFont();
|
||||
font.setPointSizeF(getScaledFontSize(mapDefaultFontSizes[getKey(*itf)]));
|
||||
mapWidgetFonts[*itf] = font;
|
||||
++itf;
|
||||
} else {
|
||||
itf = setFixedPitchFontUpdates.erase(itf);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it : mapWidgetFonts) {
|
||||
it.first->setFont(it.second);
|
||||
if (it.second.second) {
|
||||
it.first->setFont(it.second.first);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the global font for QToolTip labels
|
||||
QFont fontToolTip = qApp->font("QTipLabel");
|
||||
// Store the default QToolTip font size before ever applying any scale to it
|
||||
if (!mapDefaultFontSizes.count("QTipLabel")) {
|
||||
mapDefaultFontSizes.emplace("QTipLabel", fontToolTip.pointSize());
|
||||
// Cleanup mapDefaultFontSize to remove deleted widgets
|
||||
auto itd = mapWidgetDefaultFontSizes.begin();
|
||||
while (itd != mapWidgetDefaultFontSizes.end()) {
|
||||
if (qApp->allWidgets().contains(itd->first)) {
|
||||
++itd;
|
||||
} else {
|
||||
itd = mapWidgetDefaultFontSizes.erase(itd);
|
||||
}
|
||||
}
|
||||
|
||||
// Scale the global font for QToolTip labels, QMenu and QMessageBox instances
|
||||
QFont fontToolTip = qApp->font("QTipLabel");
|
||||
QFont fontMenu = qApp->font("QMenu");
|
||||
QFont fontMessageBox = qApp->font("QMessageBox");
|
||||
// Store their default font sizes before ever applying any scale to it
|
||||
if (!mapClassDefaultFontSizes.count("QTipLabel")) {
|
||||
mapClassDefaultFontSizes.emplace("QTipLabel", fontToolTip.pointSize());
|
||||
}
|
||||
if (!mapClassDefaultFontSizes.count("QMenu")) {
|
||||
mapClassDefaultFontSizes.emplace("QMenu", fontMenu.pointSize());
|
||||
}
|
||||
if (!mapClassDefaultFontSizes.count("QMessageBox")) {
|
||||
mapClassDefaultFontSizes.emplace("QMessageBox", fontMessageBox.pointSize());
|
||||
}
|
||||
// And give them the proper scaled size based on their default sizes if required
|
||||
double dSize = getScaledFontSize(mapClassDefaultFontSizes["QTipLabel"]);
|
||||
if (fontToolTip.pointSizeF() != dSize) {
|
||||
fontToolTip.setPointSizeF(dSize);
|
||||
qApp->setFont(fontToolTip, "QTipLabel");
|
||||
}
|
||||
dSize = getScaledFontSize(mapClassDefaultFontSizes["QMenu"]);
|
||||
if (fontMenu.pointSizeF() != dSize) {
|
||||
fontMenu.setPointSizeF(dSize);
|
||||
qApp->setFont(fontMenu, "QMenu");
|
||||
}
|
||||
dSize = getScaledFontSize(getScaledFontSize(mapClassDefaultFontSizes["QMessageBox"]));
|
||||
if (fontMessageBox.pointSizeF() != dSize) {
|
||||
fontMessageBox.setPointSizeF(dSize);
|
||||
qApp->setFont(fontMessageBox, "QMessageBox");
|
||||
}
|
||||
// And give it the proper scaled size based on its default size
|
||||
fontToolTip.setPointSizeF(getScaledFontSize(mapDefaultFontSizes["QTipLabel"]));
|
||||
qApp->setFont(fontToolTip, "QTipLabel");
|
||||
}
|
||||
|
||||
QFont getFont(FontFamily family, QFont::Weight qWeight, bool fItalic, int nPointSize)
|
||||
|
@ -101,9 +101,6 @@ namespace GUIUtil
|
||||
QString dateTimeStr(const QDateTime &datetime);
|
||||
QString dateTimeStr(qint64 nTime);
|
||||
|
||||
// Return a monospace font
|
||||
QFont fixedPitchFont();
|
||||
|
||||
// Set up widgets for address and amounts
|
||||
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent, bool fAllowURI = false);
|
||||
void setupAmountWidget(QLineEdit *widget, QWidget *parent);
|
||||
@ -331,9 +328,6 @@ namespace GUIUtil
|
||||
theme changes. */
|
||||
void setFont(const std::vector<QWidget*>& vecWidgets, FontWeight weight, int nPointSize = -1, bool fItalic = false);
|
||||
|
||||
/** Workaround to set a fixed pitch font in traditional theme while keeping track of font updates */
|
||||
void setFixedPitchFont(const std::vector<QWidget*>& vecWidgets);
|
||||
|
||||
/** Update the font of all widgets where a custom font has been set with
|
||||
GUIUtil::setFont */
|
||||
void updateFonts();
|
||||
|
@ -96,6 +96,8 @@ MasternodeList::MasternodeList(QWidget* parent) :
|
||||
timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(updateDIP3ListScheduled()));
|
||||
timer->start(1000);
|
||||
|
||||
GUIUtil::updateFonts();
|
||||
}
|
||||
|
||||
MasternodeList::~MasternodeList()
|
||||
|
@ -41,6 +41,8 @@ foreverHidden(false)
|
||||
|
||||
blockProcessTime.clear();
|
||||
setVisible(false);
|
||||
|
||||
GUIUtil::updateFonts();
|
||||
}
|
||||
|
||||
ModalOverlay::~ModalOverlay()
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QLocale>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
#include <QShowEvent>
|
||||
#include <QTimer>
|
||||
|
||||
OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
||||
@ -165,6 +166,11 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
||||
appearanceLayout->addWidget(appearance);
|
||||
ui->widgetAppearance->setLayout(appearanceLayout);
|
||||
|
||||
connect(appearance, &AppearanceWidget::appearanceChanged, [=](){
|
||||
updateWidth();
|
||||
Q_EMIT appearanceChanged();
|
||||
});
|
||||
|
||||
updatePrivateSendVisibility();
|
||||
|
||||
// Store the current PrivateSend enabled state to recover it if it gets changed but the dialog gets not accepted but declined.
|
||||
@ -245,6 +251,7 @@ void OptionsDialog::setModel(OptionsModel *_model)
|
||||
if (_model != nullptr) {
|
||||
_model->emitPrivateSendEnabledChanged();
|
||||
}
|
||||
updateWidth();
|
||||
});
|
||||
}
|
||||
|
||||
@ -307,6 +314,7 @@ void OptionsDialog::showPage(int index)
|
||||
|
||||
GUIUtil::setFont({btnActive}, GUIUtil::FontWeight::Bold, 16);
|
||||
GUIUtil::setFont(vecNormal, GUIUtil::FontWeight::Normal, 16);
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
ui->stackedWidgetOptions->setCurrentIndex(index);
|
||||
btnActive->setChecked(true);
|
||||
@ -441,6 +449,32 @@ void OptionsDialog::updatePrivateSendVisibility()
|
||||
ui->btnPrivateSend->setVisible(fEnabled);
|
||||
}
|
||||
|
||||
void OptionsDialog::updateWidth()
|
||||
{
|
||||
int nWidthWidestButton{0};
|
||||
int nButtonsVisible{0};
|
||||
for (QAbstractButton* button : pageButtons.buttons()) {
|
||||
if (!button->isVisible()) {
|
||||
continue;
|
||||
}
|
||||
QFontMetrics fm(button->font());
|
||||
nWidthWidestButton = std::max<int>(nWidthWidestButton, fm.width(button->text()));
|
||||
++nButtonsVisible;
|
||||
}
|
||||
// Add 10 per button as padding and use minimum 585 which is what we used in css before
|
||||
int nWidth = std::max<int>(585, (nWidthWidestButton + 10) * nButtonsVisible);
|
||||
setMinimumWidth(nWidth);
|
||||
resize(nWidth, height());
|
||||
}
|
||||
|
||||
void OptionsDialog::showEvent(QShowEvent* event)
|
||||
{
|
||||
if (!event->spontaneous()) {
|
||||
updateWidth();
|
||||
}
|
||||
QDialog::showEvent(event);
|
||||
}
|
||||
|
||||
ProxyAddressValidator::ProxyAddressValidator(QObject *parent) :
|
||||
QValidator(parent)
|
||||
{
|
||||
|
@ -64,7 +64,10 @@ private Q_SLOTS:
|
||||
|
||||
void updatePrivateSendVisibility();
|
||||
|
||||
void updateWidth();
|
||||
|
||||
Q_SIGNALS:
|
||||
void appearanceChanged();
|
||||
void proxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPort);
|
||||
|
||||
private:
|
||||
@ -75,6 +78,8 @@ private:
|
||||
QString previousTheme;
|
||||
AppearanceWidget* appearance;
|
||||
bool fPrivateSendEnabledPrev{false};
|
||||
|
||||
void showEvent(QShowEvent* event) override;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_QT_OPTIONSDIALOG_H
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
// Draw first line (with slightly bigger font than the second line will get)
|
||||
// Content: Date/Time, Optional IS indicator, Amount
|
||||
QFont font = fontInitial;
|
||||
font.setPointSize(font.pointSize() * 1.17);
|
||||
font.setPointSizeF(GUIUtil::getScaledFontSize(font.pointSizeF() * 1.17));
|
||||
painter->setFont(font);
|
||||
// Date/Time
|
||||
colorForeground = qvariant_cast<QColor>(indexDate.data(Qt::ForegroundRole));
|
||||
@ -83,6 +83,7 @@ public:
|
||||
|
||||
// Draw second line (with the initial font)
|
||||
// Content: Address/label, Optional Watchonly indicator
|
||||
fontInitial.setPointSizeF(GUIUtil::getScaledFontSize(fontInitial.pointSizeF()));
|
||||
painter->setFont(fontInitial);
|
||||
// Address/Label
|
||||
colorForeground = qvariant_cast<QColor>(indexAddress.data(Qt::ForegroundRole));
|
||||
@ -144,6 +145,8 @@ OverviewPage::OverviewPage(QWidget* parent) :
|
||||
ui->labelSpendable
|
||||
}, GUIUtil::FontWeight::Bold);
|
||||
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
// Recent transactions
|
||||
ui->listTransactions->setItemDelegate(txdelegate);
|
||||
// Note: minimum height of listTransactions will be set later in updateAdvancedPSUI() to reflect actual settings
|
||||
|
@ -31,6 +31,7 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget* parent) :
|
||||
GUIUtil::setFont({ui->label,
|
||||
ui->label_2,
|
||||
ui->label_3}, GUIUtil::FontWeight::Normal, 15);
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
#if QT_VERSION >= 0x040700
|
||||
ui->reqLabel->setPlaceholderText(tr("Enter a label to associate with the new receiving address"));
|
||||
|
@ -194,7 +194,7 @@ void ReceiveRequestDialog::update()
|
||||
painter.fillRect(paddedRect, GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET));
|
||||
painter.drawImage(2, 2, qrImage.scaled(QR_IMAGE_SIZE - 4, QR_IMAGE_SIZE - 4));
|
||||
// calculate ideal font size
|
||||
QFont font = GUIUtil::fixedPitchFont();
|
||||
QFont font = GUIUtil::getFontNormal();
|
||||
qreal font_size = GUIUtil::calculateIdealFontSize((paddedRect.width() - 20), info.address, font);
|
||||
font.setPointSizeF(font_size);
|
||||
// paint the address
|
||||
|
@ -1259,7 +1259,6 @@ OptionsDialog
|
||||
******************************************************/
|
||||
|
||||
QDialog#OptionsDialog {
|
||||
min-width: 585px;
|
||||
}
|
||||
|
||||
QDialog#OptionsDialog QValueComboBox,
|
||||
|
@ -462,6 +462,8 @@ RPCConsole::RPCConsole(QWidget* parent) :
|
||||
ui->banHeading
|
||||
}, GUIUtil::FontWeight::Bold, 16);
|
||||
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
GUIUtil::disableMacFocusRect(this);
|
||||
|
||||
QSettings settings;
|
||||
@ -833,7 +835,7 @@ void RPCConsole::clear(bool clearHistory)
|
||||
ui->lineEdit->setFocus();
|
||||
|
||||
// Set default style sheet
|
||||
QFontInfo fixedFontInfo(GUIUtil::fixedPitchFont());
|
||||
QFontInfo fixedFontInfo(GUIUtil::getFontNormal());
|
||||
ui->messagesWidget->document()->setDefaultStyleSheet(
|
||||
QString(
|
||||
"table { }"
|
||||
@ -841,7 +843,7 @@ void RPCConsole::clear(bool clearHistory)
|
||||
"td.message { " + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_PRIMARY) + " font-family: %1; font-size: %2; white-space:pre-wrap; } "
|
||||
"td.cmd-request, b { " + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_COMMAND) + " } "
|
||||
"td.cmd-error, .secwarning { " + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR) + " }"
|
||||
).arg(fixedFontInfo.family(), QString("%1pt").arg(consoleFontSize)).arg(consoleFontSize * 0.1)
|
||||
).arg(fixedFontInfo.family(), QString("%1pt").arg(consoleFontSize))
|
||||
);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
@ -957,6 +959,7 @@ void RPCConsole::showPage(int index)
|
||||
|
||||
GUIUtil::setFont({btnActive}, GUIUtil::FontWeight::Bold, 16);
|
||||
GUIUtil::setFont(vecNormal, GUIUtil::FontWeight::Normal, 16);
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
ui->stackedWidgetRPC->setCurrentIndex(index);
|
||||
btnActive->setChecked(true);
|
||||
|
@ -86,6 +86,8 @@ SendCoinsDialog::SendCoinsDialog(bool _fPrivateSend, QWidget* parent) :
|
||||
|
||||
addEntry();
|
||||
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
|
||||
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
|
||||
|
@ -33,8 +33,6 @@ SendCoinsEntry::SendCoinsEntry(QWidget* parent) :
|
||||
|
||||
// normal dash address field
|
||||
GUIUtil::setupAddressWidget(ui->payTo, this, true);
|
||||
// just a label for displaying dash address(es)
|
||||
ui->payTo_is->setFont(GUIUtil::fixedPitchFont());
|
||||
|
||||
GUIUtil::setFont({ui->payToLabel,
|
||||
ui->labellLabel,
|
||||
|
@ -52,9 +52,7 @@ SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget* parent) :
|
||||
ui->messageIn_VM->installEventFilter(this);
|
||||
ui->signatureIn_VM->installEventFilter(this);
|
||||
|
||||
GUIUtil::setFixedPitchFont({ui->signatureOut_SM, ui->signatureIn_VM});
|
||||
|
||||
GUIUtil::setFont({ui->signatureOut_SM}, GUIUtil::FontWeight::Normal, 11, true);
|
||||
GUIUtil::setFont({ui->signatureOut_SM, ui->signatureIn_VM}, GUIUtil::FontWeight::Normal, 11, true);
|
||||
GUIUtil::setFont({ui->signatureLabel_SM}, GUIUtil::FontWeight::Bold, 16);
|
||||
GUIUtil::setFont({ui->statusLabel_SM, ui->statusLabel_VM}, GUIUtil::FontWeight::Bold);
|
||||
|
||||
@ -111,6 +109,7 @@ void SignVerifyMessageDialog::showPage(int index)
|
||||
|
||||
GUIUtil::setFont({btnActive}, GUIUtil::FontWeight::Bold, 16);
|
||||
GUIUtil::setFont(vecNormal, GUIUtil::FontWeight::Normal, 16);
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
ui->stackedWidgetSig->setCurrentIndex(index);
|
||||
btnActive->setChecked(true);
|
||||
|
@ -159,16 +159,24 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *)
|
||||
}
|
||||
|
||||
// Draw statistic rect on top of everything else
|
||||
const int nScale = GUIUtil::getFontScale() / 2;
|
||||
const int nMarginStats = 20;
|
||||
const int nPadding = 5;
|
||||
const int nWidthStats = 160 + nScale * 3 - 2 * nPadding;
|
||||
const int nHeightStats = 110 + nScale - 2 * nPadding;
|
||||
const int nSizeMark = nWidthStats * 0.15;
|
||||
const int nWidthText = nWidthStats * 0.45;
|
||||
const int nWidthBytes = nWidthStats * 0.4;
|
||||
const int nHeightTotals = nHeightStats * 0.3;
|
||||
const int nHeightInOut = nHeightStats * 0.35;
|
||||
const int nMarginStats = 20;
|
||||
const QString strTotal = tr("Total");
|
||||
const QString strReceived = tr("Received");
|
||||
const QString strSent = tr("Sent");
|
||||
// Get a bold font for the title and a normal one for the rest
|
||||
QFont fontTotal = GUIUtil::getFont(GUIUtil::FontWeight::Bold, false, 16);
|
||||
QFont fontInOut = GUIUtil::getFont(GUIUtil::FontWeight::Normal, false, 12);
|
||||
// Use font metrics to determine minimum rect sizes depending on the font scale
|
||||
QFontMetrics fmTotal(fontTotal);
|
||||
QFontMetrics fmInOut(fontInOut);
|
||||
const int nSizeMark = fmInOut.height() + 2 * nPadding;
|
||||
const int nWidthText = fmInOut.width(strReceived) + 2 * nPadding;
|
||||
const int nWidthBytes = fmInOut.width("1000 GB") + 2 * nPadding;
|
||||
const int nHeightTotals = fmTotal.height() + 2 * nPadding;
|
||||
const int nHeightInOut = fmInOut.height() + 2 * nPadding;
|
||||
const int nWidthStats = nSizeMark + nWidthText + nWidthBytes + 2 * nPadding;
|
||||
const int nHeightStats = nHeightTotals + 2 * nHeightInOut + 2 * nPadding;
|
||||
auto addPadding = [&](QRect& rect, int nPadding) {
|
||||
rect.adjust(nPadding, nPadding, -nPadding, -nPadding);
|
||||
};
|
||||
@ -177,26 +185,23 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *)
|
||||
QRect rectContent = rectOuter;
|
||||
QRect rectContentPadded = rectContent;
|
||||
addPadding(rectContentPadded, nPadding);
|
||||
QRect rectTotals(rectContentPadded.topLeft(), QSize(nWidthStats, nHeightTotals));
|
||||
QRect rectIn(rectTotals.bottomLeft(), QSize(nWidthStats, nHeightInOut));
|
||||
QRect rectOut(rectIn.bottomLeft(), QSize(nWidthStats, nHeightInOut));
|
||||
QRect rectTotals(rectContentPadded.topLeft(), QSize(rectContentPadded.width(), nHeightTotals));
|
||||
QRect rectIn(rectTotals.bottomLeft(), QSize(rectContentPadded.width(), nHeightInOut));
|
||||
QRect rectOut(rectIn.bottomLeft(), QSize(rectContentPadded.width(), nHeightInOut));
|
||||
// Create subrects for received
|
||||
QRect rectInMark(rectIn.topLeft(), QSize(nSizeMark, nSizeMark));
|
||||
QRect rectInText(rectInMark.topRight(), QSize(nWidthText, nHeightInOut));
|
||||
QRect rectInBytes(rectInText.topRight(), QSize(nWidthBytes - nPadding, nHeightInOut));
|
||||
QRect rectInBytes(rectInText.topRight(), QSize(nWidthBytes, nHeightInOut));
|
||||
// Create subrects for sent
|
||||
QRect rectOutMark(rectOut.topLeft(), QSize(nSizeMark, nSizeMark));
|
||||
QRect rectOutText(rectOutMark.topRight(), QSize(nWidthText, nHeightInOut));
|
||||
QRect rectOutBytes(rectOutText.topRight(), QSize(nWidthBytes - nPadding, nHeightInOut));
|
||||
// Get a bold font for the title and a normal one for the rest
|
||||
QFont fontTotal = GUIUtil::getFont(GUIUtil::FontWeight::Bold, false, 16);
|
||||
QFont fontInOut = GUIUtil::getFont(GUIUtil::FontWeight::Normal, false, 12);
|
||||
QRect rectOutBytes(rectOutText.topRight(), QSize(nWidthBytes, nHeightInOut));
|
||||
// Add padding where required
|
||||
addPadding(rectTotals, nPadding);
|
||||
addPadding(rectInMark, nPadding);
|
||||
addPadding(rectInMark, 1.6 * nPadding);
|
||||
addPadding(rectInText, nPadding);
|
||||
addPadding(rectInBytes, nPadding);
|
||||
addPadding(rectOutMark, nPadding);
|
||||
addPadding(rectOutMark, 1.6 * nPadding);
|
||||
addPadding(rectOutText, nPadding);
|
||||
addPadding(rectOutBytes, nPadding);
|
||||
// Finally draw it all
|
||||
@ -205,11 +210,11 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *)
|
||||
painter.fillRect(rectContent, GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_NETSTATS));
|
||||
painter.setPen(axisCol);
|
||||
painter.setFont(fontTotal);
|
||||
painter.drawText(rectTotals, Qt::AlignLeft, tr("Totals"));
|
||||
painter.drawText(rectTotals, Qt::AlignLeft, strTotal);
|
||||
painter.setFont(fontInOut);
|
||||
painter.drawText(rectInText, Qt::AlignLeft, tr("Received"));
|
||||
painter.drawText(rectInText, Qt::AlignLeft, strReceived);
|
||||
painter.drawText(rectInBytes, Qt::AlignRight, GUIUtil::formatBytes(trafficGraphData.getLastBytesIn()));
|
||||
painter.drawText(rectOutText, Qt::AlignLeft, tr("Sent"));
|
||||
painter.drawText(rectOutText, Qt::AlignLeft, strSent);
|
||||
painter.drawText(rectOutBytes, Qt::AlignRight, GUIUtil::formatBytes(trafficGraphData.getLastBytesOut()));
|
||||
painter.setPen(green);
|
||||
painter.setBrush(green);
|
||||
|
@ -217,6 +217,8 @@ ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):
|
||||
tr("%1 is shutting down...").arg(tr(PACKAGE_NAME)) + "<br /><br />" +
|
||||
tr("Do not shut down the computer until this window disappears.")));
|
||||
setLayout(layout);
|
||||
|
||||
GUIUtil::updateFonts();
|
||||
}
|
||||
|
||||
QWidget *ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
|
||||
|
@ -62,6 +62,7 @@ WalletView::WalletView(QWidget* parent) :
|
||||
GUIUtil::setFont({transactionSumLabel,
|
||||
transactionSum,
|
||||
}, GUIUtil::FontWeight::Bold, 14);
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
hbox_buttons->addWidget(transactionSum);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user