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>
This commit is contained in:
Volker Hilsheimer 2019-06-24 22:42:28 +02:00 committed by Tor Arne Vestbø
parent cc13b99781
commit 2a756e294e

View File

@ -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()