From 1615c54db06a10e63e077495a29a0c6301116015 Mon Sep 17 00:00:00 2001
From: Reksotiv <hellfire0h@gmail.com>
Date: Tue, 14 Feb 2023 07:15:55 +0300
Subject: [PATCH] Fixed restoring app position for multiscreen

---
 qt/MainWindow.cpp | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/qt/MainWindow.cpp b/qt/MainWindow.cpp
index 5976ff4128b..e6763e6edc7 100644
--- a/qt/MainWindow.cpp
+++ b/qt/MainWindow.cpp
@@ -101,24 +101,7 @@ void SC_MainWindow::loadHistory()
                               tr( "We have reset your configuration settings due to major changes to the GUI" ) );
   }
 
-  // Restoring the ui to a previously stored place that is potentially not the primary monitor causes issues for some users. See https://github.com/simulationcraft/simc/issues/5047
-  // Until we can figure out why this is happening and can be resolved, restoring the ui position is intentionally disabled
-  if constexpr(false)
-  {
-    QVariant size                  = settings.value( "gui/size" );
-    QRect savedApplicationGeometry = geometry();
-    if ( size.isValid() )
-    {
-      savedApplicationGeometry.setSize( size.toSize() );
-    }
-    QVariant pos = settings.value( "gui/position" );
-    if ( pos.isValid() )
-    {
-      savedApplicationGeometry.moveTopLeft( pos.toPoint() );
-    }
-    setGeometry(savedApplicationGeometry);
-  }
-
+  restoreGeometry( settings.value( "gui/geometry" ).toByteArray() );
   QVariant maximized = settings.value( "gui/maximized" );
   if ( maximized.isValid() )
   {
@@ -181,8 +164,7 @@ void SC_MainWindow::saveHistory()
   QSettings settings;
   settings.beginGroup( "gui" );
   settings.setValue( "gui_version_number", SC_GUI_HISTORY_VERSION );
-  settings.setValue( "size", normalGeometry().size() );
-  settings.setValue( "position", normalGeometry().topLeft() );
+  settings.setValue( "geometry", saveGeometry() );
   settings.setValue( "maximized", bool( windowState() & Qt::WindowMaximized ) );
   settings.endGroup();