summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2020-11-05 18:14:10 +0100
committerGitHub <noreply@github.com>2020-11-05 18:14:10 +0100
commitda8aeb3678eed52deb37c22ef640b69b4c991e59 (patch)
tree727286503d9e507d03fe7bc8c8b7c169a56015ac
parentcbce15c50bfa08644f3e84d18d9f44b91a9d8c89 (diff)
parentf99b045f39b39686d95319be52e195c6a00e3292 (diff)
Merge pull request #547 from JFK422/master
Move MainWindow to the screen the cursor is on
-rw-r--r--main/main.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 31d92dbf..6456371f 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -6,6 +6,7 @@
#include <QApplication>
#include <QDir>
#include <QTranslator>
+#include <QtWidgets>
/*! \mainpage QtPass
*
@@ -101,6 +102,14 @@ int main(int argc, char *argv[]) {
QGuiApplication::setDesktopFileName("qtpass.desktop");
#endif
+
+ //Center the MainWindow on the screen the mouse pointer is currently on
+ static int cursorScreen = app.desktop()->screenNumber(app.desktop()->cursor().pos());
+ QPoint cursorScreenCenter = app.desktop()->screenGeometry(cursorScreen).center();
+ QRect windowFrameGeo = w.frameGeometry();
+ windowFrameGeo.moveCenter(cursorScreenCenter);
+ w.move(windowFrameGeo.topLeft());
+
w.show();
return SingleApplication::exec();