From f99b045f39b39686d95319be52e195c6a00e3292 Mon Sep 17 00:00:00 2001 From: Kenneth Mathis Date: Sun, 18 Oct 2020 21:51:04 +0200 Subject: Move MainWindow to the screen the cursor is on --- main/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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 #include #include +#include /*! \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(); -- cgit v1.2.3