Skip to content

Commit

Permalink
Match window size after rotating with "When opening images" setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpurcell committed Dec 8, 2024
1 parent 8c4f9ce commit d643aed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand All @@ -1211,6 +1213,7 @@ void MainWindow::resetTransformation()
{
graphicsView->resetTransformation();
graphicsView->fitOrConstrainImage();
setWindowSize(true);
}

void MainWindow::firstFile()
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MainWindow : public QMainWindow

void setTitlebarHidden(const bool shouldHide);

void setWindowSize();
void setWindowSize(const bool isFromTransform = false);

bool getIsPixmapLoaded() const;

Expand Down

0 comments on commit d643aed

Please sign in to comment.