Commit 5b9f9726 authored by Arisotura's avatar Arisotura
Browse files

UI: detect and save when window is maximized, and restore it as such. fixes #1135

parent 1cd477db
......@@ -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)
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment