Fix Message Box button size on macOS and Linux

* Fixes #10381
This commit is contained in:
Jonathan White 2024-03-30 08:01:44 -04:00
parent 9521f63b3a
commit db0b659a53
5 changed files with 6 additions and 4 deletions

View File

@ -322,6 +322,7 @@ void DatabaseOpenWidget::openDatabase()
auto btn = msgBox->addButton(tr("Open database anyway"), QMessageBox::ButtonRole::AcceptRole);
msgBox->setDefaultButton(btn);
msgBox->addButton(QMessageBox::Cancel);
msgBox->layout()->setSizeConstraint(QLayout::SetMinimumSize);
msgBox->exec();
if (msgBox->clickedButton() != btn) {
m_db.reset(new Database());

View File

@ -19,6 +19,7 @@
#include "MessageBox.h"
#include <QCheckBox>
#include <QLayout>
#include <QMap>
#include <QPushButton>
#include <QWindow>
@ -126,6 +127,7 @@ MessageBox::Button MessageBox::messageBox(QWidget* parent,
msgBox.activateWindow();
msgBox.raise();
}
msgBox.layout()->setSizeConstraint(QLayout::SetMinimumSize);
msgBox.exec();
Button returnButton = m_addedButtonLookup[msgBox.clickedButton()];

View File

@ -168,6 +168,7 @@ bool DatabaseSettingsWidgetDatabaseKey::save()
auto btn = msgBox->addButton(tr("Continue without password"), QMessageBox::ButtonRole::AcceptRole);
msgBox->addButton(QMessageBox::Cancel);
msgBox->setDefaultButton(QMessageBox::Cancel);
msgBox->layout()->setSizeConstraint(QLayout::SetMinimumSize);
msgBox->exec();
if (msgBox->clickedButton() != btn) {
return false;

View File

@ -287,6 +287,7 @@ bool DatabaseSettingsWidgetEncryption::save()
auto ok = warning.addButton(tr("Understood, keep number"), QMessageBox::ButtonRole::AcceptRole);
auto cancel = warning.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole);
warning.setDefaultButton(cancel);
warning.layout()->setSizeConstraint(QLayout::SetMinimumSize);
warning.exec();
if (warning.clickedButton() != ok) {
return false;
@ -300,6 +301,7 @@ bool DatabaseSettingsWidgetEncryption::save()
auto ok = warning.addButton(tr("Understood, keep number"), QMessageBox::ButtonRole::AcceptRole);
auto cancel = warning.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole);
warning.setDefaultButton(cancel);
warning.layout()->setSizeConstraint(QLayout::SetMinimumSize);
warning.exec();
if (warning.clickedButton() != ok) {
return false;

View File

@ -17,10 +17,6 @@ QSpinBox {
min-width: 90px;
}
QDialogButtonBox QPushButton {
min-width: 55px;
}
QCheckBox, QRadioButton {
spacing: 10px;
}