macOS: Use non-native fallback for message boxes with rich text

The NSAlert messageText and informativeText properties only allow
plain NSString, so we need to opt out of the native dialog if the
user has requested rich text for any of these properties.

Fixes: QTBUG-116757
Pick-to: 6.5
Change-Id: I3fd44ec94adad1dda1ed4dede46450a8a525d35f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 28ab45182a3fea76193146083838cca4212395d2)
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Timur Pocheptsov 2023-09-06 14:30:24 +02:00 committed by Volker Hilsheimer
parent a1e143faab
commit 1d80626400

View File

@ -91,6 +91,13 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w
if (!options())
return false;
if (Qt::mightBeRichText(options()->text()) ||
Qt::mightBeRichText(options()->informativeText())) {
// Let's fallback to non-native message box,
// we only have plain NSString/text in NSAlert.
qCDebug(lcQpaDialogs, "Message box contains text in rich text format");
return false;
}
Q_ASSERT(!m_alert);
m_alert = [NSAlert new];