Merge pull request #6787 from spycrab/qt_restore_window

Qt: Restore render widget size and position
This commit is contained in:
Anthony 2018-05-08 11:29:12 -07:00 committed by GitHub
commit cb02a4bb95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -113,6 +113,11 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainW
QSettings& settings = Settings::GetQSettings(); QSettings& settings = Settings::GetQSettings();
restoreState(settings.value(QStringLiteral("mainwindow/state")).toByteArray()); 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() MainWindow::~MainWindow()
@ -125,6 +130,12 @@ MainWindow::~MainWindow()
QSettings& settings = Settings::GetQSettings(); QSettings& settings = Settings::GetQSettings();
settings.setValue(QStringLiteral("mainwindow/state"), saveState()); 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() void MainWindow::InitControllers()
@ -547,6 +558,12 @@ bool MainWindow::RequestStop()
return true; 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) if (SConfig::GetInstance().bConfirmStop)
{ {
const Core::State state = Core::GetState(); const Core::State state = Core::GetState();
@ -629,6 +646,7 @@ void MainWindow::FullScreen()
else else
{ {
m_render_widget_size = m_render_widget->size(); m_render_widget_size = m_render_widget->size();
m_render_widget_position = m_render_widget->pos();
m_render_widget->showFullScreen(); m_render_widget->showFullScreen();
} }
} }
@ -729,6 +747,9 @@ void MainWindow::ShowRenderWidget()
m_render_widget->showNormal(); m_render_widget->showNormal();
m_render_widget->resize(m_render_widget_size); 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); SetFullScreenResolution(false);

View File

@ -193,5 +193,6 @@ private:
RegisterWidget* m_register_widget; RegisterWidget* m_register_widget;
WatchWidget* m_watch_widget; WatchWidget* m_watch_widget;
CheatsManager* m_cheats_manager; CheatsManager* m_cheats_manager;
QSize m_render_widget_size{640, 480}; QSize m_render_widget_size;
QPoint m_render_widget_position;
}; };