From 97aca502e28d9c9776caf18d3398ffaa1a7e0233 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 24 Aug 2022 08:22:00 +0300 Subject: [PATCH] Move MainWindow behind FirstRun screen (#1101) IB-7411 Signed-off-by: Raul Metsma Signed-off-by: Raul Metsma --- client/Application.cpp | 25 +++++++++++++++++++------ client/dialogs/FirstRun.cpp | 10 ++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/client/Application.cpp b/client/Application.cpp index e1e63012c..ef09e1419 100644 --- a/client/Application.cpp +++ b/client/Application.cpp @@ -60,6 +60,7 @@ class MacMenuBar {}; #include #include #include +#include #include #include #include @@ -1089,17 +1090,29 @@ void Application::showClient(const QStringList ¶ms, bool crypto, bool sign, } if( !w ) { - QSettings settings; migrateSettings(); w = new MainWindow(); - QWidgetList list = topLevelWidgets(); - for(int i = list.size() - 1; i >= 0; --i) + QWidget *prev = [=]() -> QWidget* { + for(QWidget *top: topLevelWidgets()) + { + QWidget *prev = qobject_cast(top); + if(!prev) + prev = qobject_cast(top); + if(prev && prev != w && prev->isVisible()) + return prev; + } + return nullptr; + }(); + if(prev) + w->move(prev->geometry().topLeft() + QPoint(20, 20)); +#ifdef Q_OS_LINUX + else { - MainWindow *prev = qobject_cast(list[i]); - if(prev && prev != w && prev->isVisible()) - w->move(prev->geometry().topLeft() + QPoint(20, 20)); + QRect rect = QGuiApplication::screenAt(w->pos())->availableGeometry(); + w->move(rect.center() - w->frameGeometry().adjusted(0, 0, 10, 40).center()); } +#endif } if( !params.isEmpty() ) QMetaObject::invokeMethod(w, "open", Q_ARG(QStringList,params), Q_ARG(bool,crypto), Q_ARG(bool,sign)); diff --git a/client/dialogs/FirstRun.cpp b/client/dialogs/FirstRun.cpp index 9b874237d..317582479 100644 --- a/client/dialogs/FirstRun.cpp +++ b/client/dialogs/FirstRun.cpp @@ -19,6 +19,8 @@ #include "FirstRun.h" #include "ui_FirstRun.h" + +#include "MainWindow.h" #include "Styles.h" #include @@ -36,6 +38,14 @@ FirstRun::FirstRun(QWidget *parent) setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint ); setFixedSize( size() ); setCursor(Qt::OpenHandCursor); + if(!parent) + { + for(QWidget *top: qApp->topLevelWidgets()) + { + if(MainWindow *main = qobject_cast(top)) + parent = main; + } + } if(parent) move(parent->geometry().center() - geometry().center());