diff options
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 35 | ||||
-rw-r--r-- | src/frontend/qt_sdl/main.h | 14 |
2 files changed, 39 insertions, 10 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 62c124a..8407acb 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -1226,6 +1226,10 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) sigaction(SIGINT, &sa, 0); #endif + oldW = Config::WindowWidth; + oldH = Config::WindowHeight; + oldMax = Config::WindowMaximized!=0; + setWindowTitle("melonDS " MELONDS_VERSION); setAttribute(Qt::WA_DeleteOnClose); setAcceptDrops(true); @@ -1238,11 +1242,11 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) connect(actOpenROM, &QAction::triggered, this, &MainWindow::onOpenFile); actOpenROM->setShortcut(QKeySequence(QKeySequence::StandardKey::Open)); - actOpenROMArchive = menu->addAction("Open ROM inside Archive..."); + actOpenROMArchive = menu->addAction("Open ROM inside archive..."); connect(actOpenROMArchive, &QAction::triggered, this, &MainWindow::onOpenFileArchive); actOpenROMArchive->setShortcut(QKeySequence(Qt::Key_O | Qt::CTRL | Qt::SHIFT)); - recentMenu = menu->addMenu("Open Recent"); + recentMenu = menu->addMenu("Open recent"); for (int i = 0; i < 10; ++i) { char* item = Config::RecentROMList[i]; @@ -1507,7 +1511,11 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) resize(Config::WindowWidth, Config::WindowHeight); - show(); + if (oldMax) + showMaximized(); + else + show(); + createScreenPanel(); for (int i = 0; i < 9; i++) @@ -1619,13 +1627,30 @@ void MainWindow::resizeEvent(QResizeEvent* event) int w = event->size().width(); int h = event->size().height(); - if (mainWindow != nullptr && !mainWindow->isFullScreen()) + if (!isFullScreen()) { + // this is ugly + // thing is, when maximizing the window, we first receive the resizeEvent + // with a new size matching the screen, then the changeEvent telling us that + // the maximized flag was updated + oldW = Config::WindowWidth; + oldH = Config::WindowHeight; + oldMax = isMaximized(); + Config::WindowWidth = w; Config::WindowHeight = h; } +} + +void MainWindow::changeEvent(QEvent* event) +{ + if (isMaximized() && !oldMax) + { + Config::WindowWidth = oldW; + Config::WindowHeight = oldH; + } - // TODO: detect when the window gets maximized! + Config::WindowMaximized = isMaximized() ? 1:0; } void MainWindow::keyPressEvent(QKeyEvent* event) diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index 60befde..024af8a 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -78,7 +78,7 @@ signals: void windowLimitFPSChange(); void screenLayoutChange(); - + void windowFullscreenToggle(); void swapScreensToggle(); @@ -120,7 +120,7 @@ protected: int numScreens; bool touching; - + void showCursor(); }; @@ -200,11 +200,12 @@ public: bool hasOGL; QOpenGLContext* getOGLContext(); - + void onAppStateChanged(Qt::ApplicationState state); protected: void resizeEvent(QResizeEvent* event) override; + void changeEvent(QEvent* event) override; void keyPressEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override; @@ -268,7 +269,7 @@ private slots: void onEmuStop(); void onUpdateVideoSettings(bool glchange); - + void onFullscreenToggled(); private: @@ -283,9 +284,12 @@ private: void createScreenPanel(); QString loadErrorStr(int error); - + bool pausedManually; + int oldW, oldH; + bool oldMax; + public: QWidget* panel; ScreenPanelGL* panelGL; |