diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 808da31bf1..495350951a 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -168,6 +168,8 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : } }); #endif + + updateWidth(); } OptionsDialog::~OptionsDialog() @@ -237,6 +239,7 @@ void OptionsDialog::setModel(OptionsModel *_model) if (_model != nullptr) { _model->emitPrivateSendEnabledChanged(); } + updateWidth(); }); } @@ -434,6 +437,24 @@ 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(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(585, (nWidthWidestButton + 10) * nButtonsVisible); + setMinimumWidth(nWidth); + setMaximumWidth(nWidth); +} + ProxyAddressValidator::ProxyAddressValidator(QObject *parent) : QValidator(parent) { diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 7fdbe7fff7..c6287de796 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -64,6 +64,8 @@ private Q_SLOTS: void updatePrivateSendVisibility(); + void updateWidth(); + Q_SIGNALS: void proxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPort); diff --git a/src/qt/res/css/general.css b/src/qt/res/css/general.css index a2a6484564..8adb3ae796 100644 --- a/src/qt/res/css/general.css +++ b/src/qt/res/css/general.css @@ -1259,7 +1259,6 @@ OptionsDialog ******************************************************/ QDialog#OptionsDialog { - min-width: 585px; } QDialog#OptionsDialog QValueComboBox,