mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 03:22:47 +01:00
qt: Update min/max width of OptionsDialog depending on buttons width
This commit is contained in:
parent
b4ecfdce5a
commit
d351fca6a6
@ -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<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);
|
||||
setMaximumWidth(nWidth);
|
||||
}
|
||||
|
||||
ProxyAddressValidator::ProxyAddressValidator(QObject *parent) :
|
||||
QValidator(parent)
|
||||
{
|
||||
|
@ -64,6 +64,8 @@ private Q_SLOTS:
|
||||
|
||||
void updatePrivateSendVisibility();
|
||||
|
||||
void updateWidth();
|
||||
|
||||
Q_SIGNALS:
|
||||
void proxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPort);
|
||||
|
||||
|
@ -1259,7 +1259,6 @@ OptionsDialog
|
||||
******************************************************/
|
||||
|
||||
QDialog#OptionsDialog {
|
||||
min-width: 585px;
|
||||
}
|
||||
|
||||
QDialog#OptionsDialog QValueComboBox,
|
||||
|
Loading…
Reference in New Issue
Block a user