diff --git a/src/drivers/Qt/ConsoleViewerGL.cpp b/src/drivers/Qt/ConsoleViewerGL.cpp index 5517043a..19cf3169 100644 --- a/src/drivers/Qt/ConsoleViewerGL.cpp +++ b/src/drivers/Qt/ConsoleViewerGL.cpp @@ -83,6 +83,9 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent) g_config->getOption ("SDL.AutoScale", &opt); autoScaleEna = (opt) ? true : false; + + g_config->getOption("SDL.XScale", &xscale); + g_config->getOption("SDL.YScale", &yscale); } } diff --git a/src/drivers/Qt/ConsoleViewerSDL.cpp b/src/drivers/Qt/ConsoleViewerSDL.cpp index bf81dc56..db831053 100644 --- a/src/drivers/Qt/ConsoleViewerSDL.cpp +++ b/src/drivers/Qt/ConsoleViewerSDL.cpp @@ -86,6 +86,9 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent) g_config->getOption ("SDL.AutoScale", &opt); autoScaleEna = (opt) ? true : false; + + g_config->getOption("SDL.XScale", &xscale); + g_config->getOption("SDL.YScale", &yscale); } } @@ -273,6 +276,9 @@ void ConsoleViewSDL_t::resizeEvent(QResizeEvent *event) view_height = s.height(); printf("SDL Resize: %i x %i \n", view_width, view_height); + gui_draw_area_width = view_width; + gui_draw_area_height = view_height; + reset(); } diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index cdb4ca92..a676ca52 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -82,11 +82,17 @@ consoleWin_t::consoleWin_t(QWidget *parent) : QMainWindow( parent ) { - int opt; + int opt, xWinSize = 512, yWinSize = 512; int use_SDL_video = false; - int setFullScreen = false; + int setFullScreen = false; - this->resize( 512, 512 ); + g_config->getOption( "SDL.WinSizeX", &xWinSize ); + g_config->getOption( "SDL.WinSizeY", &yWinSize ); + + if ( xWinSize < 256 ) xWinSize = 256; + if ( yWinSize < 256 ) yWinSize = 256; + + this->resize( xWinSize, yWinSize ); g_config->getOption( "SDL.Fullscreen", &setFullScreen ); g_config->setOption( "SDL.Fullscreen", 0 ); // Reset full screen config parameter to false so it is never saved this way @@ -119,13 +125,13 @@ consoleWin_t::consoleWin_t(QWidget *parent) } setWindowTitle( tr(FCEU_NAME_AND_VERSION) ); - setWindowIcon(QIcon(":fceux1.png")); + setWindowIcon(QIcon(":fceux1.png")); gameTimer = new QTimer( this ); mutex = new QMutex( QMutex::Recursive ); emulatorThread = new emulatorThread_t(); - connect(emulatorThread, &QThread::finished, emulatorThread, &QObject::deleteLater); + connect(emulatorThread, &QThread::finished, emulatorThread, &QObject::deleteLater); connect( gameTimer, &QTimer::timeout, this, &consoleWin_t::updatePeriodic ); @@ -152,8 +158,27 @@ consoleWin_t::consoleWin_t(QWidget *parent) consoleWin_t::~consoleWin_t(void) { + QSize w; QClipboard *clipboard; + // Save window size and image scaling parameters at app exit. + w = consoleWindow->size(); + + if ( viewport_GL != NULL ) + { + g_config->setOption( "SDL.XScale", viewport_GL->getScaleX() ); + g_config->setOption( "SDL.YScale", viewport_GL->getScaleY() ); + } + else if ( viewport_SDL != NULL ) + { + g_config->setOption( "SDL.XScale", viewport_SDL->getScaleX() ); + g_config->setOption( "SDL.YScale", viewport_SDL->getScaleY() ); + } + g_config->setOption( "SDL.WinSizeX", w.width() ); + g_config->setOption( "SDL.WinSizeY", w.height() ); + g_config->save(); + + // Signal Emulator Thread to Stop nes_shm->runEmulator = 0; gameTimer->stop(); diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp index 2b2cfb0d..71d1783e 100644 --- a/src/drivers/Qt/config.cpp +++ b/src/drivers/Qt/config.cpp @@ -225,11 +225,13 @@ InitConfig() config->addOption('y', "yres", "SDL.YResolution", 0); config->addOption("SDL.LastXRes", 0); config->addOption("SDL.LastYRes", 0); + config->addOption("SDL.WinSizeX", 512); + config->addOption("SDL.WinSizeY", 512); config->addOption("doublebuf", "SDL.DoubleBuffering", 1); config->addOption("autoscale", "SDL.AutoScale", 1); config->addOption("keepratio", "SDL.KeepRatio", 1); - config->addOption("xscale", "SDL.XScale", 1.0); - config->addOption("yscale", "SDL.YScale", 1.0); + config->addOption("xscale", "SDL.XScale", 2.0); + config->addOption("yscale", "SDL.YScale", 2.0); config->addOption("xstretch", "SDL.XStretch", 0); config->addOption("ystretch", "SDL.YStretch", 0); config->addOption("noframe", "SDL.NoFrame", 0);