summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-11-09 12:27:37 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-11-10 20:54:51 +0100
commit89dd5ab63054bd0a0b774129182b2c21a9f7c02e (patch)
tree82269bd6eb17a1df26082a2704164aa9c61393dc
parent1d80626400f6b86ccb13f09f4c5f5be198571694 (diff)
Cocoa MessageBox: don't use native message box if detailed text is set
As per the documentation: A message box displays a primary text to alert the user to a situation, an informative text to further explain the situation, and an optional detailed text to provide even more data if the user requests it. The AppKit NSAlert doesn't provide such a "detailed" section, and our code just added this "even more data" detailed text to the primary text. This breaks the UI when the detailed text is very long, perhaps a complete log output with dozens or even hundreds of lines of text. Since NSAlert doesn't provide a "details" space, fall-back to the non- native message box if detailed text is provided. [ChangeLog][QtWidgets][QMessageBox] On Apple platforms, the native message box is no longer used when detailed text is set. Pick-to: 6.5 Fixes: QTBUG-118992 Change-Id: I6f4764ceb8f8e57d641c0b0660223a9c26f5bd26 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 8753bb3045d020bcae33eed67a2770a4709ac7b8)
-rw-r--r--src/plugins/platforms/cocoa/qcocoamessagedialog.mm11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamessagedialog.mm b/src/plugins/platforms/cocoa/qcocoamessagedialog.mm
index b09f6bf54e..82a4c90c23 100644
--- a/src/plugins/platforms/cocoa/qcocoamessagedialog.mm
+++ b/src/plugins/platforms/cocoa/qcocoamessagedialog.mm
@@ -91,6 +91,12 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w
if (!options())
return false;
+ // NSAlert doesn't have a section for detailed text
+ if (!options()->detailedText().isEmpty()) {
+ qCWarning(lcQpaDialogs, "Message box contains detailed text");
+ return false;
+ }
+
if (Qt::mightBeRichText(options()->text()) ||
Qt::mightBeRichText(options()->informativeText())) {
// Let's fallback to non-native message box,
@@ -103,10 +109,7 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w
m_alert = [NSAlert new];
m_alert.window.title = options()->windowTitle().toNSString();
- QString text = toPlainText(options()->text());
- QString details = toPlainText(options()->detailedText());
- if (!details.isEmpty())
- text += u"\n\n"_s + details;
+ const QString text = toPlainText(options()->text());
m_alert.messageText = text.toNSString();
m_alert.informativeText = toPlainText(options()->informativeText()).toNSString();