Skip to content

Commit

Permalink
Move MainWindow behind FirstRun screen (open-eid#1101)
Browse files Browse the repository at this point in the history
IB-7411

Signed-off-by: Raul Metsma <[email protected]>

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Aug 24, 2022
1 parent fc725df commit 97aca50
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
25 changes: 19 additions & 6 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MacMenuBar {};
#include <QtCore/QXmlStreamReader>
#include <QtGui/QDesktopServices>
#include <QtGui/QFileOpenEvent>
#include <QtGui/QScreen>
#include <QtNetwork/QNetworkProxy>
#include <QtNetwork/QSslCertificate>
#include <QtNetwork/QSslConfiguration>
Expand Down Expand Up @@ -1089,17 +1090,29 @@ void Application::showClient(const QStringList &params, 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<MainWindow*>(top);
if(!prev)
prev = qobject_cast<FirstRun*>(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<MainWindow*>(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));
Expand Down
10 changes: 10 additions & 0 deletions client/dialogs/FirstRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "FirstRun.h"
#include "ui_FirstRun.h"

#include "MainWindow.h"
#include "Styles.h"

#include <common/Common.h>
Expand All @@ -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<MainWindow*>(top))
parent = main;
}
}
if(parent)
move(parent->geometry().center() - geometry().center());

Expand Down

0 comments on commit 97aca50

Please sign in to comment.