From d643aedb8a069cea54c5a5f408dd018020202d2f Mon Sep 17 00:00:00 2001 From: "J.D. Purcell" Date: Sat, 7 Dec 2024 21:06:58 -0500 Subject: [PATCH] Match window size after rotating with "When opening images" setting --- src/mainwindow.cpp | 7 +++++-- src/mainwindow.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 00d9809c..399930a1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -693,7 +693,7 @@ void MainWindow::setTitlebarHidden(const bool shouldHide) graphicsView->fitOrConstrainImage(); } -void MainWindow::setWindowSize() +void MainWindow::setWindowSize(const bool isFromTransform) { if (!getCurrentFileDetails().isPixmapLoaded) return; @@ -732,7 +732,7 @@ void MainWindow::setWindowSize() const QSize screenSize = currentScreen->size(); const QSize minWindowSize = (screenSize * minWindowResizedPercentage).boundedTo(hardLimitSize); const QSize maxWindowSize = (screenSize * maxWindowResizedPercentage).boundedTo(hardLimitSize); - const bool isZoomFixed = !graphicsView->getNavigationResetsZoom() && !graphicsView->getCalculatedZoomMode().has_value(); + const bool isZoomFixed = (!graphicsView->getNavigationResetsZoom() || isFromTransform) && !graphicsView->getCalculatedZoomMode().has_value(); const QSizeF imageSize = graphicsView->getEffectiveOriginalSize() * (isZoomFixed ? graphicsView->getZoomLevel() : 1.0); const int fitOverscan = graphicsView->getFitOverscan(); const QSize fitOverscanSize = QSize(fitOverscan * 2, fitOverscan * 2); @@ -1187,12 +1187,14 @@ void MainWindow::rotateRight() { graphicsView->rotateImage(90); graphicsView->fitOrConstrainImage(); + setWindowSize(true); } void MainWindow::rotateLeft() { graphicsView->rotateImage(-90); graphicsView->fitOrConstrainImage(); + setWindowSize(true); } void MainWindow::mirror() @@ -1211,6 +1213,7 @@ void MainWindow::resetTransformation() { graphicsView->resetTransformation(); graphicsView->fitOrConstrainImage(); + setWindowSize(true); } void MainWindow::firstFile() diff --git a/src/mainwindow.h b/src/mainwindow.h index 1731097b..7b0f5f58 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -47,7 +47,7 @@ class MainWindow : public QMainWindow void setTitlebarHidden(const bool shouldHide); - void setWindowSize(); + void setWindowSize(const bool isFromTransform = false); bool getIsPixmapLoaded() const;