aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2021-06-20 02:21:48 +0200
committerArisotura <thetotalworm@gmail.com>2021-06-20 02:21:48 +0200
commit5b9f9726251717ede5f040d276dd700278e8963e (patch)
treee9ee4c6aa5095a4362c627235eed9b50f9610d35 /src/frontend/qt_sdl
parent1cd477db7187870f24b78f5c2a73681a62ffc0e9 (diff)
UI: detect and save when window is maximized, and restore it as such. fixes #1135
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r--src/frontend/qt_sdl/main.cpp35
-rw-r--r--src/frontend/qt_sdl/main.h14
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;