diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fe2f37dc..89d62d57 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -576,21 +576,25 @@ void MainWindow::setWindowSize() const QSize hardLimitSize = currentScreen->availableSize() - windowFrameSize - extraWidgetsSize; const QSize screenSize = currentScreen->size(); const QSize minWindowSize = (screenSize * minWindowResizedPercentage).boundedTo(hardLimitSize); - const QSize maxWindowSize = (screenSize * maxWindowResizedPercentage).boundedTo(hardLimitSize); + const QSize maxWindowSize = (screenSize * qMax(maxWindowResizedPercentage, minWindowResizedPercentage)).boundedTo(hardLimitSize); const QSizeF imageSize = graphicsView->getEffectiveOriginalSize(); const int fitOverscan = graphicsView->getFitOverscan(); const QSize fitOverscanSize = QSize(fitOverscan * 2, fitOverscan * 2); + const bool enforceMinSizeBothDimensions = false; QSize targetSize = imageSize.toSize() - fitOverscanSize; - if (targetSize.width() > maxWindowSize.width() || targetSize.height() > maxWindowSize.height()) + const bool limitToMin = targetSize.width() < minWindowSize.width() && targetSize.height() < minWindowSize.height(); + const bool limitToMax = targetSize.width() > maxWindowSize.width() || targetSize.height() > maxWindowSize.height(); + if (limitToMin || limitToMax) { - const QSizeF viewSize = maxWindowSize + fitOverscanSize; + const QSizeF viewSize = (limitToMin ? minWindowSize : maxWindowSize) + fitOverscanSize; const qreal fitRatio = qMin(viewSize.width() / imageSize.width(), viewSize.height() / imageSize.height()); targetSize = (imageSize * fitRatio).toSize() - fitOverscanSize; } - targetSize = targetSize.expandedTo(minWindowSize).boundedTo(maxWindowSize); + if (enforceMinSizeBothDimensions) + targetSize = targetSize.expandedTo(minWindowSize); // Match center after new geometry // This is smoother than a single geometry set for some reason diff --git a/src/qvgraphicsview.cpp b/src/qvgraphicsview.cpp index 2ff37e5c..d0ee6b01 100644 --- a/src/qvgraphicsview.cpp +++ b/src/qvgraphicsview.cpp @@ -454,7 +454,11 @@ void QVGraphicsView::zoomToFit() void QVGraphicsView::originalSize() { - zoomAbsolute(1.0); + const bool originalSizeAsToggle = true; + if (originalSizeAsToggle && zoomLevel == 1.0) + zoomToFit(); + else + zoomAbsolute(1.0); } void QVGraphicsView::centerImage() diff --git a/src/qvgraphicsview.h b/src/qvgraphicsview.h index 5db152db..16c72a20 100644 --- a/src/qvgraphicsview.h +++ b/src/qvgraphicsview.h @@ -130,7 +130,6 @@ private slots: bool isScalingEnabled; bool isScalingTwoEnabled; bool isPastActualSizeEnabled; - int fitOverscan; bool isScrollZoomsEnabled; bool isLoopFoldersEnabled; bool isCursorZoomEnabled; @@ -138,6 +137,7 @@ private slots: int cropMode; qreal zoomMultiplier; + int fitOverscan; qreal zoomLevel; qreal appliedDpiAdjustment; qreal appliedExpensiveScaleZoomLevel;