QMessageBox: Don't add details button to native dialog helper

The "Show Details..." button is not plumbed in any way to the native
dialog, so when added to a native dialog it will just result in the
dialog being dismissed, instead of revealing any extra content in
the native dialog.

Both the iOS and Android native message dialog implementations add
the details text directly to the dialog, without any action to
explicitly reveal it.

Task-number: QTBUG-108153
Change-Id: I92e00c59b7836f633be44caebd534a47ac58be00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2022-11-10 14:45:37 +01:00
parent b7f621ccad
commit c1088d493e
2 changed files with 8 additions and 4 deletions

View File

@ -12,8 +12,8 @@
Dialog::tr("<p>Click a button to close the message box. Pressing the Escape key " \
"will activate the detected escape button (if any).")
#define MESSAGE_DETAILS \
Dialog::tr("If a message box has detailed text, the user can reveal it " \
"by pressing the Show Details... button.")
Dialog::tr("Additional detailed text can be provided, which may require user " \
"action to be revealed.")
class DialogOptionsWidget : public QGroupBox

View File

@ -843,8 +843,12 @@ void QMessageBox::addButton(QAbstractButton *button, ButtonRole role)
if (!button)
return;
removeButton(button);
d->options->addButton(button->text(), static_cast<QPlatformDialogHelper::ButtonRole>(role),
button);
// Add button to native dialog helper, unless it's the details button,
// since we don't do any plumbing for the button's action in that case.
if (button != d->detailsButton) {
d->options->addButton(button->text(),
static_cast<QPlatformDialogHelper::ButtonRole>(role), button);
}
d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role);
d->customButtonList.append(button);
d->autoAddOkButton = false;