From 179a480941ea91324e9e7c044cf74c4f9bd69b8d Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Fri, 30 Nov 2012 12:56:48 +0200 Subject: Cocoa: create dialogs as NSPanels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NSPanels have builtin support to work with modal sessions. Task-number: QTBUG-28111 Change-Id: Ifeb6de03129e77aad744b3989931964c375cdbc7 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c3b2139998..f786e6969f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -149,8 +149,8 @@ static bool isMouseEvent(NSEvent *ev) - (BOOL)canBecomeKeyWindow { - // Only tool windows should become key for popup types: - if (m_cocoaPlatformWindow->window()->type() == Qt::Tool) + // Only tool or dialog windows should become key: + if (m_cocoaPlatformWindow->window()->type() == Qt::Tool || m_cocoaPlatformWindow->window()->type() == Qt::Dialog) return YES; return NO; } @@ -300,8 +300,8 @@ void QCocoaWindow::setVisible(bool visible) [m_nsWindow orderFront: nil]; } - // We want the events to properly reach the popup - if (window()->type() == Qt::Popup) + // We want the events to properly reach the popup and dialog + if (window()->type() == Qt::Popup || window()->type() == Qt::Dialog) [(NSPanel *)m_nsWindow setWorksWhenModal:YES]; } } else { @@ -666,14 +666,18 @@ NSWindow * QCocoaWindow::createNSWindow() NSWindow *createdWindow = 0; // Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen) - if ((type & Qt::Popup) == Qt::Popup) { + // and dialogs + if ((type & Qt::Popup) == Qt::Popup || (type & Qt::Dialog) == Qt::Dialog) { QNSPanel *window; window = [[QNSPanel alloc] initWithContentRect:frame styleMask: styleMask backing:NSBackingStoreBuffered defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up // before the window is shown and needs a proper window.). - [window setHasShadow:YES]; + if ((type & Qt::Popup) == Qt::Popup) + [window setHasShadow:YES]; + else + setWindowShadow(flags); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { -- cgit v1.2.3