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)
This commit is contained in:
parent
1d80626400
commit
89dd5ab630
@ -91,6 +91,12 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w
|
|||||||
if (!options())
|
if (!options())
|
||||||
return false;
|
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()) ||
|
if (Qt::mightBeRichText(options()->text()) ||
|
||||||
Qt::mightBeRichText(options()->informativeText())) {
|
Qt::mightBeRichText(options()->informativeText())) {
|
||||||
// Let's fallback to non-native message box,
|
// 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 = [NSAlert new];
|
||||||
m_alert.window.title = options()->windowTitle().toNSString();
|
m_alert.window.title = options()->windowTitle().toNSString();
|
||||||
|
|
||||||
QString text = toPlainText(options()->text());
|
const QString text = toPlainText(options()->text());
|
||||||
QString details = toPlainText(options()->detailedText());
|
|
||||||
if (!details.isEmpty())
|
|
||||||
text += u"\n\n"_s + details;
|
|
||||||
m_alert.messageText = text.toNSString();
|
m_alert.messageText = text.toNSString();
|
||||||
m_alert.informativeText = toPlainText(options()->informativeText()).toNSString();
|
m_alert.informativeText = toPlainText(options()->informativeText()).toNSString();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user