From 0e9a41588f2bb5c33e3de1f871ad18a6fd8ce6bb Mon Sep 17 00:00:00 2001 From: "J.D. Purcell" Date: Sun, 27 Aug 2023 17:14:54 -0400 Subject: [PATCH] When "window matches image size" changes, enable/disable size controls accordingly And some code deduplication. --- src/qvoptionsdialog.cpp | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/qvoptionsdialog.cpp b/src/qvoptionsdialog.cpp index ebb88e48..8e61a3fb 100644 --- a/src/qvoptionsdialog.cpp +++ b/src/qvoptionsdialog.cpp @@ -64,6 +64,7 @@ QVOptionsDialog::QVOptionsDialog(QWidget *parent) : #endif syncSettings(false, true); + connect(ui->windowResizeComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &QVOptionsDialog::windowResizeComboBoxCurrentIndexChanged); connect(ui->langComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &QVOptionsDialog::languageComboBoxCurrentIndexChanged); syncShortcuts(); updateButtonBox(); @@ -136,17 +137,7 @@ void QVOptionsDialog::syncSettings(bool defaults, bool makeConnections) ui->titlebarRadioButton2, ui->titlebarRadioButton3}, "titlebarmode", defaults, makeConnections); // windowresizemode syncComboBox(ui->windowResizeComboBox, "windowresizemode", defaults, makeConnections); - if (ui->windowResizeComboBox->currentIndex() == 0) { - ui->minWindowResizeLabel->setEnabled(false); - ui->minWindowResizeSpinBox->setEnabled(false); - ui->maxWindowResizeLabel->setEnabled(false); - ui->maxWindowResizeSpinBox->setEnabled(false); - } else { - ui->minWindowResizeLabel->setEnabled(true); - ui->minWindowResizeSpinBox->setEnabled(true); - ui->maxWindowResizeLabel->setEnabled(true); - ui->maxWindowResizeSpinBox->setEnabled(true); - } + windowResizeComboBoxCurrentIndexChanged(ui->windowResizeComboBox->currentIndex()); // minwindowresizedpercentage syncSpinBox(ui->minWindowResizeSpinBox, "minwindowresizedpercentage", defaults, makeConnections); // maxwindowresizedperecentage @@ -445,20 +436,11 @@ void QVOptionsDialog::scalingCheckboxStateChanged(int arg1) void QVOptionsDialog::windowResizeComboBoxCurrentIndexChanged(int index) { - if (index == 0) - { - ui->minWindowResizeLabel->setEnabled(false); - ui->minWindowResizeSpinBox->setEnabled(false); - ui->maxWindowResizeLabel->setEnabled(false); - ui->maxWindowResizeSpinBox->setEnabled(false); - } - else - { - ui->minWindowResizeLabel->setEnabled(true); - ui->minWindowResizeSpinBox->setEnabled(true); - ui->maxWindowResizeLabel->setEnabled(true); - ui->maxWindowResizeSpinBox->setEnabled(true); - } + bool enableRelatedControls = index != 0; + ui->minWindowResizeLabel->setEnabled(enableRelatedControls); + ui->minWindowResizeSpinBox->setEnabled(enableRelatedControls); + ui->maxWindowResizeLabel->setEnabled(enableRelatedControls); + ui->maxWindowResizeSpinBox->setEnabled(enableRelatedControls); } void QVOptionsDialog::populateLanguages()