From 285295981191e8600e5faf7833f5475985a0a1c6 Mon Sep 17 00:00:00 2001 From: spycrab Date: Tue, 8 May 2018 16:00:20 +0200 Subject: [PATCH] Qt: Restore render widget size and position --- Source/Core/DolphinQt2/MainWindow.cpp | 21 +++++++++++++++++++++ Source/Core/DolphinQt2/MainWindow.h | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index dde2f11c15..af820bf582 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -113,6 +113,11 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters) : QMainW QSettings& settings = Settings::GetQSettings(); restoreState(settings.value(QStringLiteral("mainwindow/state")).toByteArray()); + m_render_widget_size = + QSize(SConfig::GetInstance().iRenderWindowWidth, SConfig::GetInstance().iRenderWindowHeight); + + m_render_widget_position = + QPoint(SConfig::GetInstance().iRenderWindowXPos, SConfig::GetInstance().iRenderWindowYPos); } MainWindow::~MainWindow() @@ -125,6 +130,12 @@ MainWindow::~MainWindow() QSettings& settings = Settings::GetQSettings(); settings.setValue(QStringLiteral("mainwindow/state"), saveState()); + + SConfig::GetInstance().iRenderWindowWidth = m_render_widget_size.width(); + SConfig::GetInstance().iRenderWindowHeight = m_render_widget_size.height(); + + SConfig::GetInstance().iRenderWindowXPos = m_render_widget_position.x(); + SConfig::GetInstance().iRenderWindowYPos = m_render_widget_position.y(); } void MainWindow::InitControllers() @@ -547,6 +558,12 @@ bool MainWindow::RequestStop() return true; } + if (!m_render_widget->isFullScreen()) + { + m_render_widget_size = m_render_widget->size(); + m_render_widget_position = m_render_widget->pos(); + } + if (SConfig::GetInstance().bConfirmStop) { const Core::State state = Core::GetState(); @@ -629,6 +646,7 @@ void MainWindow::FullScreen() else { m_render_widget_size = m_render_widget->size(); + m_render_widget_position = m_render_widget->pos(); m_render_widget->showFullScreen(); } } @@ -729,6 +747,9 @@ void MainWindow::ShowRenderWidget() m_render_widget->showNormal(); m_render_widget->resize(m_render_widget_size); + + if (m_render_widget_position.x() != -1) + m_render_widget->move(m_render_widget_position); } SetFullScreenResolution(false); diff --git a/Source/Core/DolphinQt2/MainWindow.h b/Source/Core/DolphinQt2/MainWindow.h index e8b6ab6f11..12bfdfafde 100644 --- a/Source/Core/DolphinQt2/MainWindow.h +++ b/Source/Core/DolphinQt2/MainWindow.h @@ -193,5 +193,6 @@ private: RegisterWidget* m_register_widget; WatchWidget* m_watch_widget; CheatsManager* m_cheats_manager; - QSize m_render_widget_size{640, 480}; + QSize m_render_widget_size; + QPoint m_render_widget_position; };