diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-11-21 13:38:05 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-12-04 19:15:37 +0100 |
commit | 31973f3ff32c837fd031d6ed386ebdb2e75cbc1e (patch) | |
tree | 13621ae713bd3751a559b41f066f0a93ac32659f /src/plugins | |
parent | 8a18466e38779b63c19e281e92031cebaedbcba5 (diff) |
Teach QErrorMessage to use native dialog helper if available
And implement for macOS. The default modality of the QErrorMessage
on macOS now depends on whether the dialog has a parent or not.
The QErrorMessage must be hidden and re-shown again after each message,
so that the native dialog has a chance to recreate itself.
Change-Id: I474ed35d6271118834fac8e97f6f540a6fb89b8c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamessagedialog.mm | 16 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosmessagedialog.mm | 3 |
3 files changed, 17 insertions, 5 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp index 97ae5064bd..05dd671122 100644 --- a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp +++ b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp @@ -54,6 +54,9 @@ bool QAndroidPlatformMessageDialogHelper::show(Qt::WindowFlags windowFlags, if (!opt.data()) return false; + if (opt->supressionCheckBoxEnabled()) + return false; // Can't support + m_javaMessageDialog.callMethod<void>("setIcon", "(I)V", opt->icon()); QString str = htmlText(opt->windowTitle()); diff --git a/src/plugins/platforms/cocoa/qcocoamessagedialog.mm b/src/plugins/platforms/cocoa/qcocoamessagedialog.mm index 3d3970953d..84aea950c3 100644 --- a/src/plugins/platforms/cocoa/qcocoamessagedialog.mm +++ b/src/plugins/platforms/cocoa/qcocoamessagedialog.mm @@ -180,6 +180,8 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w StandardButton::Ok, ButtonRole::AcceptRole); } + m_alert.showsSuppressionButton = options()->supressionCheckBoxEnabled(); + qCDebug(lcQpaDialogs) << "Showing" << m_alert; if (windowModality == Qt::WindowModal) { @@ -230,6 +232,15 @@ void QCocoaMessageDialog::processResponse(NSModalResponse response) { qCDebug(lcQpaDialogs) << "Processing response" << response << "for" << m_alert; + // We can't re-use the same dialog for the next show() anyways, + // since the options may have changed, so get rid of it now, + // before we emit anything that might recurse back to hide/show/etc. + auto alert = std::exchange(m_alert, nil); + [alert autorelease]; + + if (alert.showsSuppressionButton) + emit supressionCheckBoxChanged(alert.suppressionButton.state == NSControlStateValueOn); + if (response >= NSAlertFirstButtonReturn) { // Safe range for user-defined modal responses if (response == kModalResponseDialogHidden) { @@ -270,11 +281,6 @@ void QCocoaMessageDialog::processResponse(NSModalResponse response) if (m_eventLoop) m_eventLoop->exit(response); - - // We can't re-use the same dialog for the next show() anyways, - // since the options may have changed, so get rid of it now. - [m_alert release]; - m_alert = nil; } void QCocoaMessageDialog::hide() diff --git a/src/plugins/platforms/ios/qiosmessagedialog.mm b/src/plugins/platforms/ios/qiosmessagedialog.mm index 1ac1bd0b97..1f39a94172 100644 --- a/src/plugins/platforms/ios/qiosmessagedialog.mm +++ b/src/plugins/platforms/ios/qiosmessagedialog.mm @@ -92,6 +92,9 @@ bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality win || windowModality == Qt::NonModal) // We can only do modal dialogs return false; + if (options()->supressionCheckBoxEnabled()) + return false; // Can't support + m_alertController = [[UIAlertController alertControllerWithTitle:options()->windowTitle().toNSString() message:messageTextPlain().toNSString() |