diff options
| author | Salanto <62221668+Salanto@users.noreply.github.com> | 2024-07-12 13:23:40 +0200 |
|---|---|---|
| committer | Salanto <62221668+Salanto@users.noreply.github.com> | 2024-07-12 13:23:40 +0200 |
| commit | e34b2534edc6513cc57bb71875be4d48e74c73a7 (patch) | |
| tree | 5051cb89b0f994fa44136ee6f9402d1846d9d1e6 /src/aoapplication.cpp | |
| parent | 8fac2ada62a5256bb0ba563d3e696762cf861a7d (diff) | |
Restore position in AOApplication
Diffstat (limited to 'src/aoapplication.cpp')
| -rw-r--r-- | src/aoapplication.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index 686c88c0..2ee66219 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -51,18 +51,7 @@ void AOApplication::construct_lobby() w_lobby = new Lobby(this, net_manager); - auto point = Options::getInstance().windowPosition("lobby"); - if (!Options::getInstance().restoreWindowPositionEnabled() || !point.has_value() || !pointExistsOnScreen(point.value())) - { - QRect geometry = QGuiApplication::primaryScreen()->geometry(); - int x = (geometry.width() - w_lobby->width()) / 2; - int y = (geometry.height() - w_lobby->height()) / 2; - w_lobby->move(x, y); - } - else - { - w_lobby->move(point->x(), point->y()); - } + centerOrMoveWidgetOnPrimaryScreen(w_lobby); if (Options::getInstance().discordEnabled()) { @@ -104,10 +93,7 @@ void AOApplication::construct_courtroom() w_courtroom = new Courtroom(this); - QRect geometry = QGuiApplication::primaryScreen()->geometry(); - int x = (geometry.width() - w_courtroom->width()) / 2; - int y = (geometry.height() - w_courtroom->height()) / 2; - w_courtroom->move(x, y); + centerOrMoveWidgetOnPrimaryScreen(w_courtroom); if (demo_server != nullptr) { @@ -245,6 +231,24 @@ bool AOApplication::pointExistsOnScreen(QPoint point) return false; } +void AOApplication::centerOrMoveWidgetOnPrimaryScreen(QWidget *widget) +{ + auto point = Options::getInstance().windowPosition(widget->objectName()); + qDebug() << widget->objectName(); + qDebug() << point.has_value(); + if (!Options::getInstance().restoreWindowPositionEnabled() || !point.has_value() || !pointExistsOnScreen(point.value())) + { + QRect geometry = QGuiApplication::primaryScreen()->geometry(); + int x = (geometry.width() - widget->width()) / 2; + int y = (geometry.height() - widget->height()) / 2; + widget->move(x, y); + } + else + { + widget->move(point->x(), point->y()); + } +} + #if (defined(_WIN32) || defined(_WIN64)) void AOApplication::load_bass_plugins() { |
