diff options
| author | gal20 <71563441+gal20@users.noreply.github.com> | 2021-02-10 00:42:31 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-09 23:42:31 +0100 | 
| commit | d63f7977f83fb4bc48c633c3b1ecbfa23423370f (patch) | |
| tree | 974cc2d7a33e15d80c3af8600a6fbb7b55cc7c41 /src | |
| parent | a7029aebae2d09c2dd666a5832a90e227305bab1 (diff) | |
Remove code duplication in `onChangeScreenSize` (#968)
Diffstat (limited to 'src')
| -rw-r--r-- | src/frontend/qt_sdl/main.cpp | 43 | ||||
| -rw-r--r-- | src/frontend/qt_sdl/main.h | 3 | 
2 files changed, 5 insertions, 41 deletions
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<ScreenHandler*>(panel)->screenGetMinSize(factor) + diff);  }  void MainWindow::onChangeScreenRotation(QAction* act) diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index 9bfcd0a..0009551 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -100,12 +100,11 @@ public:      QTimer* setupMouseTimer();      void updateMouseTimer();      QTimer* mouseTimer; +    QSize screenGetMinSize(int factor);  protected:      void screenSetupLayout(int w, int h); -    QSize screenGetMinSize(); -      void screenOnMousePress(QMouseEvent* event);      void screenOnMouseRelease(QMouseEvent* event);      void screenOnMouseMove(QMouseEvent* event);  |