Fix grid settings dialog not restoring defaults when closed with X button

This commit is contained in:
GriffinR 2024-10-24 12:10:47 -04:00
parent 958b71afbb
commit 971a8b7b49

View file

@ -117,6 +117,7 @@ void GridSettingsDialog::init() {
connect(ui->button_LinkDimensions, &QAbstractButton::toggled, [this](bool on) { m_dimensionsLinked = on; }); connect(ui->button_LinkDimensions, &QAbstractButton::toggled, [this](bool on) { m_dimensionsLinked = on; });
connect(ui->button_LinkOffsets, &QAbstractButton::toggled, [this](bool on) { m_offsetsLinked = on; }); connect(ui->button_LinkOffsets, &QAbstractButton::toggled, [this](bool on) { m_offsetsLinked = on; });
connect(ui->colorInput, &ColorInputWidget::colorChanged, this, &GridSettingsDialog::onColorChanged); connect(ui->colorInput, &ColorInputWidget::colorChanged, this, &GridSettingsDialog::onColorChanged);
connect(this, &GridSettingsDialog::rejected, [this] { setSettings(m_originalSettings); });
updateInput(); updateInput();
} }
@ -218,11 +219,10 @@ void GridSettingsDialog::dialogButtonClicked(QAbstractButton *button) {
auto role = ui->buttonBox->buttonRole(button); auto role = ui->buttonBox->buttonRole(button);
if (role == QDialogButtonBox::AcceptRole) { if (role == QDialogButtonBox::AcceptRole) {
// "OK" // "OK"
close(); accept();
} else if (role == QDialogButtonBox::RejectRole) { } else if (role == QDialogButtonBox::RejectRole) {
// "Cancel" // "Cancel"
setSettings(m_originalSettings); reject();
close();
} else if (role == QDialogButtonBox::ResetRole) { } else if (role == QDialogButtonBox::ResetRole) {
// "Restore Defaults" // "Restore Defaults"
setSettings(m_defaultSettings); setSettings(m_defaultSettings);