diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-10-26 20:12:00 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-11-16 15:17:19 +0100 |
commit | e5f777638b6a32adc6245bf276af9c887b4c9b0f (patch) | |
tree | 49289aa0e60fe30486199e8a778e085f16f6776b /src/plugins | |
parent | 91170aba0f465f9881483bcb93f319d608528002 (diff) |
Plumb QMessageBox::iconPixmap() to QPlatformMessageDialogHelper
For now this plumbs the QPixmap directly, but as a follow up we should
teach QMessageBox to deal with QIcons instead, and rejig the plumbing
correspondingly.
Change-Id: I51dee4240082abf0acb33b6ade553327295a99bd
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamessagedialog.mm | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamessagedialog.mm b/src/plugins/platforms/cocoa/qcocoamessagedialog.mm index c21fbc2ce4..3d3970953d 100644 --- a/src/plugins/platforms/cocoa/qcocoamessagedialog.mm +++ b/src/plugins/platforms/cocoa/qcocoamessagedialog.mm @@ -12,6 +12,7 @@ #include <QtGui/qtextdocument.h> #include <QtGui/private/qguiapplication_p.h> +#include <QtGui/private/qcoregraphics_p.h> #include <QtGui/qpa/qplatformtheme.h> #include <AppKit/NSAlert.h> @@ -90,8 +91,18 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w m_alert.messageText = text.toNSString(); m_alert.informativeText = toPlainText(options()->informativeText()).toNSString(); - switch (options()->icon()) { - case QMessageDialogOptions::NoIcon: + switch (auto standardIcon = options()->icon()) { + case QMessageDialogOptions::NoIcon: { + // We only reflect the pixmap icon if the standard icon is unset, + // as setting a standard icon will also set a corresponding pixmap + // icon, which we don't want since it conflicts with the platform. + // If the user has set an explicit pixmap icon however, the standard + // icon will be NoIcon, so we're good. + QPixmap iconPixmap = options()->iconPixmap(); + if (!iconPixmap.isNull()) + m_alert.icon = [NSImage imageFromQImage:iconPixmap.toImage()]; + break; + } case QMessageDialogOptions::Information: case QMessageDialogOptions::Question: [m_alert setAlertStyle:NSAlertStyleInformational]; @@ -104,8 +115,6 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w break; } - // FIXME: Propagate iconPixmap through dialog options - bool defaultButtonAdded = false; bool cancelButtonAdded = false; |