summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2019-06-24 22:42:28 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-06-26 15:49:01 +0000
commit2a756e294e2efa4bcb2b51afd1c20822df251f29 (patch)
treeaf0563f4eec1c8060556057ec953424bb3f7c359 /src/plugins/platforms
parentcc13b99781b0bbf5f9d09b2c5b081a085762cd0c (diff)
macOS: lower the splash screen when a modal dialog blocks it
This fixes the usability issue of a modal dialog showing up behind a splash screen, not visible to the user, but blocking user input and the application startup sequence until discarded. [ChangeLog][QtWidgets][QSlashScreen] On macOS, lower the splash screen when a modal dialog is shown to make sure the user sees the dialog. Change-Id: Ibae768f76909d930cb25dcf5cee31edc5f15c29a Fixes: QTBUG-49576 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 232c74b1e9..b5d63f8331 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -217,6 +217,25 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
connect(qGuiApp, &QGuiApplication::focusWindowChanged,
this, &QCocoaIntegration::focusWindowChanged);
+
+ static auto splashScreenHider = QMacKeyValueObserver(NSApp, @"modalWindow", []{
+ const QWindowList allWindows = QGuiApplication::topLevelWindows();
+ for (QWindow *window : allWindows) {
+ if ((window->flags() & Qt::SplashScreen) == Qt::SplashScreen) {
+ QCocoaWindow *platformWindow = static_cast<QCocoaWindow*>(window->handle());
+ NSWindow *splashWindow = platformWindow->view().window;
+ if (!splashWindow)
+ continue;
+ if (NSApp.modalWindow) {
+ NSInteger originalLevel = splashWindow.level;
+ splashWindow.level = NSNormalWindowLevel;
+ window->setProperty("_q_levelBeforeModalSession", (qlonglong)originalLevel);
+ } else if (NSInteger originalLevel = window->property("_q_levelBeforeModalSession").toLongLong()) {
+ splashWindow.level = originalLevel;
+ }
+ }
+ }
+ });
}
QCocoaIntegration::~QCocoaIntegration()