From d63f7977f83fb4bc48c633c3b1ecbfa23423370f Mon Sep 17 00:00:00 2001 From: gal20 <71563441+gal20@users.noreply.github.com> Date: Wed, 10 Feb 2021 00:42:31 +0200 Subject: Remove code duplication in `onChangeScreenSize` (#968) --- src/frontend/qt_sdl/main.cpp | 43 ++++--------------------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) (limited to 'src/frontend/qt_sdl/main.cpp') diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 460457c..3e26489 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -681,13 +681,13 @@ void ScreenHandler::screenSetupLayout(int w, int h) numScreens = Frontend::GetScreenTransforms(screenMatrix[0], screenKind); } -QSize ScreenHandler::screenGetMinSize() +QSize ScreenHandler::screenGetMinSize(int factor = 1) { bool isHori = (Config::ScreenRotation == 1 || Config::ScreenRotation == 3); int gap = Config::ScreenGap; - int w = 256; - int h = 192; + int w = 256 * factor; + int h = 192 * factor; if (Config::ScreenLayout == 0) // natural { @@ -2272,43 +2272,8 @@ void MainWindow::onChangeSavestateSRAMReloc(bool checked) void MainWindow::onChangeScreenSize() { int factor = ((QAction*)sender())->data().toInt(); - - bool isHori = (Config::ScreenRotation == 1 || Config::ScreenRotation == 3); - int gap = Config::ScreenGap; - - int w = 256*factor; - int h = 192*factor; - QSize diff = size() - panel->size(); - - if (Config::ScreenLayout == 0) // natural - { - if (isHori) - resize(QSize(h+gap+h, w) + diff); - else - resize(QSize(w, h+gap+h) + diff); - } - else if (Config::ScreenLayout == 1) // vertical - { - if (isHori) - resize(QSize(h, w+gap+w) + diff); - else - resize(QSize(w, h+gap+h) + diff); - } - else if (Config::ScreenLayout == 2) // horizontal - { - if (isHori) - resize(QSize(h+gap+h, w) + diff); - else - resize(QSize(w+gap+w, h) + diff); - } - else // hybrid - { - if (isHori) - return resize(QSize(h+gap+h, 3*w +(4*gap) / 3) + diff); - else - return resize(QSize(3*w +(4*gap) / 3, h+gap+h) + diff); - } + resize(dynamic_cast(panel)->screenGetMinSize(factor) + diff); } void MainWindow::onChangeScreenRotation(QAction* act) -- cgit v1.2.3