Fallback to primary screen if screen under pointer not found

Fixes #3252

Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
This commit is contained in:
Felix Weilbach 2021-05-05 11:55:30 +02:00
parent 8716877e61
commit aadee15008

View file

@ -116,7 +116,10 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
void OwncloudWizard::centerWindow() void OwncloudWizard::centerWindow()
{ {
const auto wizardWindow = window(); const auto wizardWindow = window();
const auto screenGeometry = QGuiApplication::screenAt(wizardWindow->pos())->geometry(); const auto screen = QGuiApplication::screenAt(wizardWindow->pos())
? QGuiApplication::screenAt(wizardWindow->pos())
: QGuiApplication::primaryScreen();
const auto screenGeometry = screen->geometry();
const auto windowGeometry = wizardWindow->geometry(); const auto windowGeometry = wizardWindow->geometry();
const auto newWindowPosition = screenGeometry.center() - QPoint(windowGeometry.width() / 2, windowGeometry.height() / 2); const auto newWindowPosition = screenGeometry.center() - QPoint(windowGeometry.width() / 2, windowGeometry.height() / 2);
wizardWindow->move(newWindowPosition); wizardWindow->move(newWindowPosition);