From abeaf425a5fe73bdc8c7777caf10fbda702e0ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 31 Jan 2025 14:13:37 +0100 Subject: [PATCH] macOS: Emit font dialog change when dialog is not active window The NSFontPanel emits changeFont even when not the active window, and applications are expected to update their views accordingly. As the changeFont action message is sent through the responder chain we were only picking up the changes when the font panel was active, thanks to the NSWindow delegate we were installing on the panel. But when the active window is one of our other windows, we were failing to process the changeFont message in our QNSView. We now handle the message by forwarding it to the font dialog delegate, so that we enter the same code path as before, and emit the right signals for QFontDialog and friends. Change-Id: I97427c73fe46f129ca11afa6b2c222bf0f0fb0af Reviewed-by: Timur Pocheptsov (cherry picked from commit 3d42f31243ce52e517e09843b93f40b79925652f) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit c04a7aa2c6dd60135d2442ae327db3a80bc2241a) --- .../platforms/cocoa/qcocoafontdialoghelper.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index 5cdf6bf02c..8e449f13db 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -14,6 +14,7 @@ #include "qcocoafontdialoghelper.h" #include "qcocoahelpers.h" #include "qcocoaeventdispatcher.h" +#include "qnsview.h" #if !CGFLOAT_DEFINED typedef float CGFloat; // Should only not be defined on 32-bit platforms @@ -255,6 +256,18 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); @end +@interface QNSView (FontPanel) +- (void)changeFont:(id)sender; +@end + +@implementation QNSView (FontPanel) +- (void)changeFont:(id)sender +{ + if (auto *delegate = qt_objc_cast(NSFontPanel.sharedFontPanel.delegate)) + [delegate changeFont:sender]; +} +@end + QT_BEGIN_NAMESPACE class QCocoaFontPanel