diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2018-07-18 17:51:11 +0300 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-08-14 04:39:05 +0000 |
commit | 43f5377fad3f462a033d836fd71a6eb356462c11 (patch) | |
tree | c74b7efca3809e2294c1c3594bfd6744e9659571 /src/widgets/dialogs/qmessagebox.cpp | |
parent | edbac716911e49a6b0f81b328e65756f95cb1f0a (diff) |
Make QMessageBox window with the detailed text closable
QMessageBox window ignores QCloseEvent if it was created
with Ok button and the detailed text was set. But it can
be closed if it contains only one button.
Make it closable if there are two buttons and one of them
is the "Show Details..." button.
[ChangeLog][QtWidgets][QMessageBox] A message box with two
buttons, one of which is the "Show Details..." button,
can be closed by clicking the X button on the window's
title bar.
Task-number: QTBUG-69526
Change-Id: Iba09e38561eb3898dc2aecfd38d8519d512a71c1
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/dialogs/qmessagebox.cpp')
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 52ca88891e..6de952a1d3 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1022,6 +1022,16 @@ void QMessageBoxPrivate::detectEscapeButton() return; } + // If there are two buttons and one of them is the "Show Details..." + // button, then make the other one the escape button + if (buttons.count() == 2 && detailsButton) { + auto idx = buttons.indexOf(detailsButton); + if (idx != -1) { + detectedEscapeButton = buttons.at(1 - idx); + return; + } + } + // if the message box has one RejectRole button, make it the escape button for (auto *button : buttons) { if (buttonBox->buttonRole(button) == QDialogButtonBox::RejectRole) { |