diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index fe74d2135e..bd2b94ee72 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -924,6 +924,9 @@ void BitcoinGUI::optionsClicked() OptionsDialog dlg(this, enableWallet); dlg.setModel(clientModel->getOptionsModel()); + connect(&dlg, &OptionsDialog::appearanceChanged, [=]() { + updateWidth(); + }); dlg.exec(); updatePrivateSendVisibility(); @@ -1171,6 +1174,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(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(980, (nWidthWidestButton + 30) * (nButtonsVisible + 1)); + setMinimumWidth(nWidth); + setMaximumWidth(nWidth); } void BitcoinGUI::updateToolBarShortcuts() @@ -1490,6 +1513,10 @@ void BitcoinGUI::showEvent(QShowEvent *event) openRepairAction->setEnabled(true); aboutAction->setEnabled(true); optionsAction->setEnabled(true); + + if (!event->spontaneous()) { + updateWidth(); + } } #ifdef ENABLE_WALLET diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index a9c048fd75..169118c8f5 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -331,6 +331,8 @@ private Q_SLOTS: void showModalOverlay(); void updatePrivateSendVisibility(); + + void updateWidth(); }; class UnitDisplayStatusBarControl : public QLabel