mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
rework window size/maximized save/restore
This commit is contained in:
parent
7b709e6847
commit
2451f3fed8
@ -37,10 +37,6 @@ namespace Config
|
||||
{
|
||||
using namespace melonDS;
|
||||
|
||||
int WindowWidth;
|
||||
int WindowHeight;
|
||||
bool WindowMaximized;
|
||||
|
||||
int ScreenRotation;
|
||||
int ScreenGap;
|
||||
int ScreenLayout;
|
||||
@ -206,10 +202,6 @@ LegacyEntry LegacyFile[] =
|
||||
|
||||
{"JoystickID", 0, "JoystickID", true},
|
||||
|
||||
{"WindowWidth", 0, "Window0.Width", true},
|
||||
{"WindowHeight", 0, "Window0.Height", true},
|
||||
{"WindowMax", 1, "Window0.Maximized", true},
|
||||
|
||||
{"ScreenRotation", 0, "Window0.ScreenRotation", true},
|
||||
{"ScreenGap", 0, "Window0.ScreenGap", true},
|
||||
{"ScreenLayout", 0, "Window0.ScreenLayout", true},
|
||||
|
@ -151,10 +151,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
extern int WindowWidth;
|
||||
extern int WindowHeight;
|
||||
extern bool WindowMaximized;
|
||||
|
||||
extern int ScreenRotation;
|
||||
extern int ScreenGap;
|
||||
extern int ScreenLayout;
|
||||
|
@ -227,10 +227,6 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||
}
|
||||
#endif
|
||||
|
||||
oldW = Config::WindowWidth;
|
||||
oldH = Config::WindowHeight;
|
||||
oldMax = Config::WindowMaximized;
|
||||
|
||||
showOSD = windowCfg.GetBool("ShowOSD");
|
||||
|
||||
setWindowTitle("melonDS " MELONDS_VERSION);
|
||||
@ -598,7 +594,7 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||
}
|
||||
setMenuBar(menubar);
|
||||
|
||||
resize(Config::WindowWidth, Config::WindowHeight);
|
||||
//resize(curW, curH);
|
||||
|
||||
if (localCfg.GetString("Firmware.Username") == "Arisotura")
|
||||
actMPNewInstance->setText("Fart");
|
||||
@ -610,9 +606,18 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||
move(frameGeo.topLeft());
|
||||
#endif
|
||||
|
||||
if (oldMax)
|
||||
/*if (oldMax)
|
||||
showMaximized();
|
||||
else
|
||||
show();*/
|
||||
std::string geom = windowCfg.GetString("Geometry");
|
||||
if (!geom.empty())
|
||||
{
|
||||
QByteArray raw = QByteArray::fromStdString(geom);
|
||||
QByteArray dec = QByteArray::fromBase64(raw, QByteArray::Base64Encoding | QByteArray::AbortOnBase64DecodingErrors);
|
||||
if (!dec.isEmpty())
|
||||
restoreGeometry(dec);
|
||||
}
|
||||
show();
|
||||
|
||||
createScreenPanel();
|
||||
@ -720,6 +725,12 @@ void MainWindow::osdAddMessage(unsigned int color, const char* msg)
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
QByteArray geom = saveGeometry();
|
||||
QByteArray enc = geom.toBase64(QByteArray::Base64Encoding);
|
||||
windowCfg.SetString("Geometry", enc.toStdString());
|
||||
|
||||
Config::Save();
|
||||
|
||||
if (hasOGL)
|
||||
{
|
||||
// we intentionally don't unpause here
|
||||
@ -808,37 +819,6 @@ void MainWindow::drawScreenGL()
|
||||
return glpanel->drawScreenGL();
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
int w = event->size().width();
|
||||
int h = event->size().height();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Config::WindowMaximized = isMaximized() ? 1:0;
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->isAutoRepeat()) return;
|
||||
|
@ -127,9 +127,6 @@ public:
|
||||
void osdAddMessage(unsigned int color, const char* msg);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void changeEvent(QEvent* event) override;
|
||||
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
||||
@ -241,9 +238,6 @@ private:
|
||||
bool pauseOnLostFocus;
|
||||
bool pausedManually;
|
||||
|
||||
int oldW, oldH;
|
||||
bool oldMax;
|
||||
|
||||
int test_num;
|
||||
|
||||
int windowID;
|
||||
|
Loading…
Reference in New Issue
Block a user