iOS: Support message box at startup without relying on screen's window
Task-number: QTBUG-121781 Change-Id: Iafc911dad6c668799383f423e38ab389c29688b4 Reviewed-by: Doris Verria <doris.verria@qt.io>
This commit is contained in:
parent
e48a9aca5d
commit
eb9923c67e
@ -88,10 +88,15 @@ int infoPlistValue(NSString* key, int defaultValue)
|
||||
UIWindow *presentationWindow(QWindow *window)
|
||||
{
|
||||
UIWindow *uiWindow = window ? reinterpret_cast<UIView *>(window->winId()).window : nullptr;
|
||||
#if !defined(Q_OS_VISIONOS)
|
||||
if (!uiWindow)
|
||||
uiWindow = qt_apple_sharedApplication().keyWindow;
|
||||
#endif
|
||||
if (!uiWindow) {
|
||||
auto *scenes = [qt_apple_sharedApplication().connectedScenes allObjects];
|
||||
if (scenes.count > 0) {
|
||||
auto *windowScene = static_cast<UIWindowScene*>(scenes[0]);
|
||||
uiWindow = windowScene.keyWindow;
|
||||
if (!uiWindow && windowScene.windows.count)
|
||||
uiWindow = windowScene.windows[0];
|
||||
}
|
||||
}
|
||||
return uiWindow;
|
||||
}
|
||||
|
||||
|
@ -117,13 +117,9 @@ bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality win
|
||||
}
|
||||
|
||||
UIWindow *window = presentationWindow(parent);
|
||||
if (!window) {
|
||||
qCDebug(lcQpaWindow, "Attempting to exec a dialog without any window/widget visible.");
|
||||
if (!window)
|
||||
return false;
|
||||
|
||||
auto *primaryScreen = static_cast<QIOSScreen*>(QGuiApplication::primaryScreen()->handle());
|
||||
Q_ASSERT(primaryScreen);
|
||||
|
||||
window = primaryScreen->uiWindow();
|
||||
if (window.hidden) {
|
||||
// With a window hidden, an attempt to present view controller
|
||||
// below fails with a warning, that a view "is not a part of
|
||||
@ -131,10 +127,6 @@ bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality win
|
||||
// as unhiding it is what hides the splash screen.
|
||||
window.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (!window)
|
||||
return false;
|
||||
|
||||
[window.rootViewController presentViewController:m_alertController animated:YES completion:nil];
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user