From e6fb9f44a74cf35fe03251520a49a3f52e6ee6be Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 17 Apr 2021 17:41:17 -0700 Subject: [PATCH] Qt: Restore maximized state when starting (fixes #487) --- CHANGES | 1 + src/platform/qt/Window.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index 593265406..bd354bc40 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,7 @@ Other fixes: - Qt: Fix smudged window icon on Windows - Qt: Fix saving settings enabling camera when camera name changes (fixes mgba.io/i/2125) - Qt: Fix frames getting backlogged (fixes mgba.io/i/2122) + - Qt: Restore maximized state when starting (fixes mgba.io/i/487) Misc: - Core: Truncate preloading ROMs that slightly exceed max size (fixes mgba.io/i/2093) - GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 3a66cb9af..3c223bd40 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -668,6 +668,7 @@ void Window::showEvent(QShowEvent* event) { m_wasOpened = true; resizeFrame(m_screenWidget->sizeHint()); QVariant windowPos = m_config->getQtOption("windowPos"); + bool maximized = m_config->getQtOption("maximized").toBool(); QRect geom = windowHandle()->screen()->availableGeometry(); if (!windowPos.isNull() && geom.contains(windowPos.toPoint())) { move(windowPos.toPoint()); @@ -676,6 +677,9 @@ void Window::showEvent(QShowEvent* event) { rect.moveCenter(geom.center()); move(rect.topLeft()); } + if (maximized) { + showMaximized(); + } if (m_fullscreenOnStart) { enterFullScreen(); m_fullscreenOnStart = false; @@ -700,6 +704,7 @@ void Window::hideEvent(QHideEvent* event) { void Window::closeEvent(QCloseEvent* event) { emit shutdown(); m_config->setQtOption("windowPos", pos()); + m_config->setQtOption("maximized", isMaximized()); if (m_savedScale > 0) { m_config->setOption("height", GBA_VIDEO_VERTICAL_PIXELS * m_savedScale);