CheckableMessageBox: Simplify checkbox setup

If the dialog is shown, the checkbox must be unchecked, because
otherwise the dialog would not have been shown.

Change-Id: I34e8034975baef710997e0cdb3c7d2f8b0c94cd2
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Eike Ziller
2023-05-17 13:00:47 +02:00
parent 8121575067
commit 2cd2324963

View File

@@ -64,19 +64,11 @@ static QMessageBox::StandardButton exec(
return acceptButton;
msgBox.setCheckBox(new QCheckBox);
msgBox.checkBox()->setChecked(false);
std::visit(
[&msgBox](auto &&decider) {
using T = std::decay_t<decltype(decider)>;
msgBox.checkBox()->setText(decider.text);
if constexpr (std::is_same_v<T, CheckableMessageBox::BoolDecision>) {
msgBox.checkBox()->setChecked(decider.doNotAskAgain);
} else if constexpr (std::is_same_v<T, CheckableMessageBox::SettingsDecision>) {
msgBox.checkBox()->setChecked(
decider.settings->value(decider.settingsSubKey, false).toBool());
} else if constexpr (std::is_same_v<T, CheckableMessageBox::AspectDecision>) {
msgBox.checkBox()->setChecked(decider.aspect.value());
}
},
*decider);
}