From bb5fbe24eaae5f9941bc54451bd82eaf3a1cb8bf Mon Sep 17 00:00:00 2001 From: "J.D. Purcell" Date: Sat, 7 Oct 2023 17:05:51 -0400 Subject: [PATCH] Add "Fill Window" zoom mode --- src/actionmanager.cpp | 18 ++++-- src/mainwindow.cpp | 55 +++++++++--------- src/mainwindow.h | 10 ++-- src/qvgraphicsview.cpp | 121 ++++++++++++++++++++-------------------- src/qvgraphicsview.h | 30 +++++----- src/qvnamespace.h | 20 +++---- src/qvoptionsdialog.cpp | 22 ++++---- src/qvoptionsdialog.h | 2 +- src/qvoptionsdialog.ui | 6 +- src/settingsmanager.cpp | 2 +- src/shortcutmanager.cpp | 3 +- 11 files changed, 152 insertions(+), 137 deletions(-) diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 7b4802e5..b5904b7b 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -258,7 +258,8 @@ QMenu *ActionManager::buildViewMenu(bool addIcon, QWidget *parent) addCloneOfAction(viewMenu, "zoomout"); addCloneOfAction(viewMenu, "originalsize"); addCloneOfAction(viewMenu, "zoomtofit"); - addCloneOfAction(viewMenu, "navigationresetszoom"); + addCloneOfAction(viewMenu, "fillwindow"); + addCloneOfAction(viewMenu, "navresetszoom"); viewMenu->addSeparator(); addCloneOfAction(viewMenu, "rotateright"); addCloneOfAction(viewMenu, "rotateleft"); @@ -634,9 +635,11 @@ void ActionManager::actionTriggered(QAction *triggeredAction, MainWindow *releva } else if (key == "originalsize") { relevantWindow->originalSize(); } else if (key == "zoomtofit") { - relevantWindow->setZoomToFitEnabled(triggeredAction->isChecked()); - } else if (key == "navigationresetszoom") { - relevantWindow->setNavigationResetsZoomEnabled(triggeredAction->isChecked()); + relevantWindow->setZoomToFit(triggeredAction->isChecked()); + } else if (key == "fillwindow") { + relevantWindow->setFillWindow(triggeredAction->isChecked()); + } else if (key == "navresetszoom") { + relevantWindow->setNavigationResetsZoom(triggeredAction->isChecked()); } else if (key == "rotateright") { relevantWindow->rotateRight(); } else if (key == "rotateleft") { @@ -765,10 +768,15 @@ void ActionManager::initializeActionLibrary() zoomToFitAction->setCheckable(true); actionLibrary.insert("zoomtofit", zoomToFitAction); + auto *fillWindowAction = new QAction(QIcon::fromTheme("zoom-fit-best"), tr("Fill &Window")); + fillWindowAction->setData({"disable"}); + fillWindowAction->setCheckable(true); + actionLibrary.insert("fillwindow", fillWindowAction); + auto *navigationResetsZoomAction = new QAction(tr("&Navigation Resets Zoom")); navigationResetsZoomAction->setData({"disable"}); navigationResetsZoomAction->setCheckable(true); - actionLibrary.insert("navigationresetszoom", navigationResetsZoomAction); + actionLibrary.insert("navresetszoom", navigationResetsZoomAction); auto *rotateRightAction = new QAction(QIcon::fromTheme("object-rotate-right"), tr("Rotate &Right")); rotateRightAction->setData({"disable"}); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 20bbdb12..ce843625 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -55,8 +55,8 @@ MainWindow::MainWindow(QWidget *parent, const QJsonObject &windowSessionState) : // Connect graphicsview signals connect(graphicsView, &QVGraphicsView::fileChanged, this, &MainWindow::fileChanged); connect(graphicsView, &QVGraphicsView::zoomLevelChanged, this, &MainWindow::zoomLevelChanged); - connect(graphicsView, &QVGraphicsView::zoomToFitChanged, this, &MainWindow::syncZoomToFitChecked); - connect(graphicsView, &QVGraphicsView::navigationResetsZoomChanged, this, &MainWindow::syncNavigationResetsZoomChecked); + connect(graphicsView, &QVGraphicsView::calculatedZoomModeChanged, this, &MainWindow::syncCalculatedZoomMode); + connect(graphicsView, &QVGraphicsView::navigationResetsZoomChanged, this, &MainWindow::syncNavigationResetsZoom); connect(graphicsView, &QVGraphicsView::cancelSlideshow, this, &MainWindow::cancelSlideshow); // Initialize escape shortcut @@ -113,9 +113,6 @@ MainWindow::MainWindow(QWidget *parent, const QJsonObject &windowSessionState) : connect(menuBar(), &QMenuBar::triggered, this, [this](QAction *triggeredAction){ ActionManager::actionTriggered(triggeredAction, this); }); - // Initialize checkable actions - syncZoomToFitChecked(); - syncNavigationResetsZoomChecked(); // Add all actions to this window so keyboard shortcuts are always triggered // using virtual menu to hold them so i can connect to the triggered signal @@ -211,6 +208,9 @@ void MainWindow::showEvent(QShowEvent *event) ui->fullscreenLabel->setMinimumHeight(menuBar()->sizeHint().height()); } + syncCalculatedZoomMode(); + syncNavigationResetsZoom(); + if (!sessionStateToLoad.isEmpty()) { loadSessionState(sessionStateToLoad, false); @@ -408,19 +408,20 @@ void MainWindow::zoomLevelChanged() buildWindowTitle(); } -void MainWindow::syncZoomToFitChecked() +void MainWindow::syncCalculatedZoomMode() { - const auto actions = qvApp->getActionManager().getAllClonesOfAction("zoomtofit", this); - const bool value = graphicsView->getZoomToFitEnabled(); - for (const auto &action : actions) - action->setChecked(value); + const bool isZoomToFit = graphicsView->getCalculatedZoomMode() == Qv::CalculatedZoomMode::ZoomToFit; + const bool isFillWindow = graphicsView->getCalculatedZoomMode() == Qv::CalculatedZoomMode::FillWindow; + for (const auto &action : qvApp->getActionManager().getAllClonesOfAction("zoomtofit", this)) + action->setChecked(isZoomToFit); + for (const auto &action : qvApp->getActionManager().getAllClonesOfAction("fillwindow", this)) + action->setChecked(isFillWindow); } -void MainWindow::syncNavigationResetsZoomChecked() +void MainWindow::syncNavigationResetsZoom() { - const auto actions = qvApp->getActionManager().getAllClonesOfAction("navigationresetszoom", this); - const bool value = graphicsView->getNavigationResetsZoomEnabled(); - for (const auto &action : actions) + const bool value = graphicsView->getNavigationResetsZoom(); + for (const auto &action : qvApp->getActionManager().getAllClonesOfAction("navresetszoom", this)) action->setChecked(value); } @@ -1166,14 +1167,19 @@ void MainWindow::zoomOut() graphicsView->zoomOut(); } -void MainWindow::setZoomToFitEnabled(bool value) +void MainWindow::setZoomToFit(const bool value) +{ + graphicsView->setCalculatedZoomMode(value ? std::make_optional(Qv::CalculatedZoomMode::ZoomToFit) : std::nullopt); +} + +void MainWindow::setFillWindow(const bool value) { - graphicsView->setZoomToFitEnabled(value); + graphicsView->setCalculatedZoomMode(value ? std::make_optional(Qv::CalculatedZoomMode::FillWindow) : std::nullopt); } -void MainWindow::setNavigationResetsZoomEnabled(bool value) +void MainWindow::setNavigationResetsZoom(const bool value) { - graphicsView->setNavigationResetsZoomEnabled(value); + graphicsView->setNavigationResetsZoom(value); } void MainWindow::originalSize() @@ -1184,25 +1190,25 @@ void MainWindow::originalSize() void MainWindow::rotateRight() { graphicsView->rotateImage(90); - graphicsView->zoomToFit(); + graphicsView->fitOrConstrainImage(); } void MainWindow::rotateLeft() { graphicsView->rotateImage(-90); - graphicsView->zoomToFit(); + graphicsView->fitOrConstrainImage(); } void MainWindow::mirror() { graphicsView->mirrorImage(); - graphicsView->zoomToFit(); + graphicsView->fitOrConstrainImage(); } void MainWindow::flip() { graphicsView->flipImage(); - graphicsView->zoomToFit(); + graphicsView->fitOrConstrainImage(); } void MainWindow::firstFile() @@ -1249,12 +1255,7 @@ void MainWindow::saveFrameAs() saveDialog->setAcceptMode(QFileDialog::AcceptSave); saveDialog->open(); connect(saveDialog, &QFileDialog::fileSelected, this, [=](const QString &fileName){ - graphicsView->originalSize(); - for(int i=0; i < graphicsView->getLoadedMovie().frameCount(); i++) - nextFrame(); - graphicsView->getLoadedMovie().currentPixmap().save(fileName, nullptr, 100); - graphicsView->zoomToFit(); }); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 493a1939..96220969 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -89,9 +89,11 @@ class MainWindow : public QMainWindow void zoomOut(); - void setZoomToFitEnabled(bool value); + void setZoomToFit(const bool value); - void setNavigationResetsZoomEnabled(bool value); + void setFillWindow(const bool value); + + void setNavigationResetsZoom(const bool value); void originalSize(); @@ -150,9 +152,9 @@ public slots: void zoomLevelChanged(); - void syncZoomToFitChecked(); + void syncCalculatedZoomMode(); - void syncNavigationResetsZoomChecked(); + void syncNavigationResetsZoom(); void disableActions(); diff --git a/src/qvgraphicsview.cpp b/src/qvgraphicsview.cpp index e4b450df..f984647f 100644 --- a/src/qvgraphicsview.cpp +++ b/src/qvgraphicsview.cpp @@ -282,10 +282,11 @@ void QVGraphicsView::executeClickAction(const Qv::ViewportClickAction action) { if (action == Qv::ViewportClickAction::ZoomToFit) { - if (!getZoomToFitEnabled()) - setZoomToFitEnabled(true); - else - centerImage(); + setCalculatedZoomMode(Qv::CalculatedZoomMode::ZoomToFit); + } + else if (action == Qv::ViewportClickAction::FillWindow) + { + setCalculatedZoomMode(Qv::CalculatedZoomMode::FillWindow); } else if (action == Qv::ViewportClickAction::OriginalSize) { @@ -430,8 +431,8 @@ void QVGraphicsView::postLoad() if (!loadIsFromSessionRestore) { - if (isNavigationResetsZoomEnabled && !isZoomToFitEnabled) - setZoomToFitEnabled(true); + if (navigationResetsZoom && calculatedZoomMode != defaultCalculatedZoomMode) + setCalculatedZoomMode(defaultCalculatedZoomMode); else fitOrConstrainImage(); } @@ -445,17 +446,17 @@ void QVGraphicsView::postLoad() loadIsFromSessionRestore = false; } -void QVGraphicsView::zoomIn(const QPoint &pos) +void QVGraphicsView::zoomIn() { - zoomRelative(zoomMultiplier, pos); + zoomRelative(zoomMultiplier); } -void QVGraphicsView::zoomOut(const QPoint &pos) +void QVGraphicsView::zoomOut() { - zoomRelative(qPow(zoomMultiplier, -1), pos); + zoomRelative(qPow(zoomMultiplier, -1)); } -void QVGraphicsView::zoomRelative(qreal relativeLevel, const QPoint &pos) +void QVGraphicsView::zoomRelative(qreal relativeLevel, const std::optional &pos) { const qreal absoluteLevel = zoomLevel * relativeLevel; @@ -465,17 +466,17 @@ void QVGraphicsView::zoomRelative(qreal relativeLevel, const QPoint &pos) zoomAbsolute(absoluteLevel, pos); } -void QVGraphicsView::zoomAbsolute(const qreal absoluteLevel, const QPoint &pos) +void QVGraphicsView::zoomAbsolute(const qreal absoluteLevel, const std::optional &pos, const bool isApplyingCalculation) { - if (!isApplyingZoomToFit) - setZoomToFitEnabled(false); + if (!isApplyingCalculation) + setCalculatedZoomMode({}); if (pos != lastZoomEventPos) { lastZoomEventPos = pos; lastZoomRoundingError = QPointF(); } - const QPointF scenePos = mapToScene(pos) - lastZoomRoundingError; + const QPointF scenePos = pos.has_value() ? mapToScene(pos.value()) - lastZoomRoundingError : QPointF(); if (appliedExpensiveScaleZoomLevel != 0.0) { @@ -492,13 +493,13 @@ void QVGraphicsView::zoomAbsolute(const qreal absoluteLevel, const QPoint &pos) scrollHelper->cancelAnimation(); // If we have a point to zoom towards and cursor zooming is enabled - if (pos != QPoint(-1, -1) && isCursorZoomEnabled) + if (pos.has_value() && isCursorZoomEnabled) { const QPointF p1mouse = mapFromScene(scenePos); - const QPointF move = p1mouse - pos; + const QPointF move = p1mouse - pos.value(); horizontalScrollBar()->setValue(horizontalScrollBar()->value() + (move.x() * (isRightToLeft() ? -1 : 1))); verticalScrollBar()->setValue(verticalScrollBar()->value() + move.y()); - lastZoomRoundingError = mapToScene(pos) - scenePos; + lastZoomRoundingError = mapToScene(pos.value()) - scenePos; constrainBoundsTimer->start(); } else if (!loadIsFromSessionRestore) @@ -510,34 +511,38 @@ void QVGraphicsView::zoomAbsolute(const qreal absoluteLevel, const QPoint &pos) emitZoomLevelChangedTimer->start(); } -bool QVGraphicsView::getZoomToFitEnabled() const +const std::optional &QVGraphicsView::getCalculatedZoomMode() const { - return isZoomToFitEnabled; + return calculatedZoomMode; } -void QVGraphicsView::setZoomToFitEnabled(bool value) +void QVGraphicsView::setCalculatedZoomMode(const std::optional &value) { - if (isZoomToFitEnabled == value) + if (calculatedZoomMode == value) + { + if (calculatedZoomMode.has_value()) + centerImage(); return; + } - isZoomToFitEnabled = value; - if (isZoomToFitEnabled) - zoomToFit(); + calculatedZoomMode = value; + if (calculatedZoomMode.has_value()) + recalculateZoom(); - emit zoomToFitChanged(); + emit calculatedZoomModeChanged(); } -bool QVGraphicsView::getNavigationResetsZoomEnabled() const +bool QVGraphicsView::getNavigationResetsZoom() const { - return isNavigationResetsZoomEnabled; + return navigationResetsZoom; } -void QVGraphicsView::setNavigationResetsZoomEnabled(bool value) +void QVGraphicsView::setNavigationResetsZoom(const bool value) { - if (isNavigationResetsZoomEnabled == value) + if (navigationResetsZoom == value) return; - isNavigationResetsZoomEnabled = value; + navigationResetsZoom = value; emit navigationResetsZoomChanged(); } @@ -601,9 +606,9 @@ void QVGraphicsView::animatedFrameChanged(QRect rect) } } -void QVGraphicsView::zoomToFit() +void QVGraphicsView::recalculateZoom() { - if (!getCurrentFileDetails().isPixmapLoaded) + if (!getCurrentFileDetails().isPixmapLoaded || !calculatedZoomMode.has_value()) return; QSizeF effectiveImageSize = getEffectiveOriginalSize(); @@ -620,20 +625,8 @@ void QVGraphicsView::zoomToFit() // Each mode will check if the rounded image size already produces the desired fit, // in which case we can use exactly 1.0 to avoid unnecessary scaling - switch (cropMode) { - case Qv::FitMode::OnlyHeight: - if (qRound(effectiveImageSize.height()) == viewSize.height()) - targetRatio = 1.0; - else - targetRatio = fitYRatio; - break; - case Qv::FitMode::OnlyWidth: - if (qRound(effectiveImageSize.width()) == viewSize.width()) - targetRatio = 1.0; - else - targetRatio = fitXRatio; - break; - default: + switch (calculatedZoomMode.value()) { + case Qv::CalculatedZoomMode::ZoomToFit: if ((qRound(effectiveImageSize.height()) == viewSize.height() && qRound(effectiveImageSize.width()) <= viewSize.width()) || (qRound(effectiveImageSize.width()) == viewSize.width() && qRound(effectiveImageSize.height()) <= viewSize.height())) { @@ -653,14 +646,23 @@ void QVGraphicsView::zoomToFit() targetRatio = qMin(fitXRatio, fitYRatio); } break; + case Qv::CalculatedZoomMode::FillWindow: + if ((qRound(effectiveImageSize.height()) == viewSize.height() && qRound(effectiveImageSize.width()) >= viewSize.width()) || + (qRound(effectiveImageSize.width()) == viewSize.width() && qRound(effectiveImageSize.height()) >= viewSize.height())) + { + targetRatio = 1.0; + } + else + { + targetRatio = qMax(fitXRatio, fitYRatio); + } + break; } if (targetRatio > 1.0 && !isPastActualSizeEnabled) targetRatio = 1.0; - isApplyingZoomToFit = true; - zoomAbsolute(targetRatio); - isApplyingZoomToFit = false; + zoomAbsolute(targetRatio, {}, true); } void QVGraphicsView::originalSize() @@ -704,9 +706,10 @@ const QJsonObject QVGraphicsView::getSessionState() const state["vScroll"] = verticalScrollBar()->value(); - state["navResetsZoom"] = isNavigationResetsZoomEnabled; + state["navResetsZoom"] = navigationResetsZoom; - state["zoomToFit"] = isZoomToFitEnabled; + if (calculatedZoomMode.has_value()) + state["calcZoomMode"] = static_cast(calculatedZoomMode.value()); return state; } @@ -730,12 +733,12 @@ void QVGraphicsView::loadSessionState(const QJsonObject &state) verticalScrollBar()->setValue(state["vScroll"].toInt()); - isNavigationResetsZoomEnabled = state["navResetsZoom"].toBool(); + navigationResetsZoom = state["navResetsZoom"].toBool(); - isZoomToFitEnabled = state["zoomToFit"].toBool(); + calculatedZoomMode = state.contains("calcZoomMode") ? std::make_optional(static_cast(state["calcZoomMode"].toInt())) : std::nullopt; emit navigationResetsZoomChanged(); - emit zoomToFitChanged(); + emit calculatedZoomModeChanged(); } void QVGraphicsView::setLoadIsFromSessionRestore(const bool value) @@ -848,8 +851,8 @@ void QVGraphicsView::goToFile(const GoToFileMode &mode, int index) void QVGraphicsView::fitOrConstrainImage() { - if (isZoomToFitEnabled) - zoomToFit(); + if (calculatedZoomMode.has_value()) + recalculateZoom(); else scrollHelper->constrain(true); } @@ -957,8 +960,8 @@ void QVGraphicsView::settingsUpdated() else isScalingTwoEnabled = settingsManager.getBoolean("scalingtwoenabled"); - //cropmode - cropMode = settingsManager.getEnum("cropmode"); + //calculatedzoommode + defaultCalculatedZoomMode = settingsManager.getEnum("calculatedzoommode"); //scalefactor zoomMultiplier = 1.0 + (settingsManager.getInteger("scalefactor") / 100.0); diff --git a/src/qvgraphicsview.h b/src/qvgraphicsview.h index d35dce4e..9e229747 100644 --- a/src/qvgraphicsview.h +++ b/src/qvgraphicsview.h @@ -5,6 +5,7 @@ #include "qvimagecore.h" #include "axislocker.h" #include "scrollhelper.h" +#include #include #include #include @@ -44,24 +45,24 @@ class QVGraphicsView : public QGraphicsView void reloadFile(); - void zoomIn(const QPoint &pos = QPoint(-1, -1)); + void zoomIn(); - void zoomOut(const QPoint &pos = QPoint(-1, -1)); + void zoomOut(); - void zoomRelative(const qreal relativeLevel, const QPoint &pos = QPoint(-1, -1)); + void zoomRelative(const qreal relativeLevel, const std::optional &pos = {}); - void zoomAbsolute(const qreal absoluteLevel, const QPoint &pos = QPoint(-1, -1)); + void zoomAbsolute(const qreal absoluteLevel, const std::optional &pos = {}, const bool isApplyingCalculation = false); - bool getZoomToFitEnabled() const; - void setZoomToFitEnabled(bool value); + const std::optional &getCalculatedZoomMode() const; + void setCalculatedZoomMode(const std::optional &value); - bool getNavigationResetsZoomEnabled() const; - void setNavigationResetsZoomEnabled(bool value); + bool getNavigationResetsZoom() const; + void setNavigationResetsZoom(const bool value); void applyExpensiveScaling(); void removeExpensiveScaling(); - void zoomToFit(); + void recalculateZoom(); void originalSize(); void centerImage(); @@ -102,7 +103,7 @@ class QVGraphicsView : public QGraphicsView void zoomLevelChanged(); - void zoomToFitChanged(); + void calculatedZoomModeChanged(); void navigationResetsZoomChanged(); @@ -172,7 +173,7 @@ private slots: bool isOneToOnePixelSizingEnabled {true}; bool isConstrainedPositioningEnabled {true}; bool isConstrainedSmallCenteringEnabled {true}; - Qv::FitMode cropMode {Qv::FitMode::WholeImage}; + Qv::CalculatedZoomMode defaultCalculatedZoomMode {Qv::CalculatedZoomMode::ZoomToFit}; qreal zoomMultiplier {1.25}; Qv::ViewportClickAction doubleClickAction {Qv::ViewportClickAction::None}; @@ -189,14 +190,13 @@ private slots: Qv::ViewportScrollAction altVerticalScrollAction {Qv::ViewportScrollAction::None}; Qv::ViewportScrollAction altHorizontalScrollAction {Qv::ViewportScrollAction::None}; - bool isZoomToFitEnabled {true}; - bool isApplyingZoomToFit {false}; - bool isNavigationResetsZoomEnabled {true}; + std::optional calculatedZoomMode {Qv::CalculatedZoomMode::ZoomToFit}; + bool navigationResetsZoom {true}; bool loadIsFromSessionRestore {false}; qreal zoomLevel {1.0}; qreal appliedDpiAdjustment {1.0}; qreal appliedExpensiveScaleZoomLevel {0.0}; - QPoint lastZoomEventPos {-1, -1}; + std::optional lastZoomEventPos; QPointF lastZoomRoundingError; QVImageCore imageCore {this}; diff --git a/src/qvnamespace.h b/src/qvnamespace.h index b0b06dd8..b82ba52d 100644 --- a/src/qvnamespace.h +++ b/src/qvnamespace.h @@ -19,6 +19,12 @@ namespace Qv CenterOnScreen = 2 }; + enum class CalculatedZoomMode + { + ZoomToFit = 0, + FillWindow = 1 + }; + enum class ClickOrDrag { Click = 0, @@ -33,13 +39,6 @@ namespace Qv DisplayP3 = 3 }; - enum class FitMode - { - WholeImage = 0, - OnlyHeight = 1, - OnlyWidth = 2 - }; - enum class PreloadMode { Disabled = 0, @@ -70,9 +69,10 @@ namespace Qv { None = 0, ZoomToFit = 1, - OriginalSize = 2, - ToggleFullScreen = 3, - ToggleTitlebarHidden = 4 + FillWindow = 2, + OriginalSize = 3, + ToggleFullScreen = 4, + ToggleTitlebarHidden = 5 }; enum class ViewportDragAction diff --git a/src/qvoptionsdialog.cpp b/src/qvoptionsdialog.cpp index e8749c81..a78ca275 100644 --- a/src/qvoptionsdialog.cpp +++ b/src/qvoptionsdialog.cpp @@ -198,8 +198,8 @@ void QVOptionsDialog::syncSettings(bool defaults, bool makeConnections) syncCheckbox(ui->cursorZoomCheckbox, "cursorzoom", defaults, makeConnections); // onetoonepixelsizing syncCheckbox(ui->oneToOnePixelSizingCheckbox, "onetoonepixelsizing", defaults, makeConnections); - // cropmode - syncComboBox(ui->cropModeComboBox, "cropmode", defaults, makeConnections); + // calculatedzoommode + syncComboBox(ui->zoomDefaultComboBox, "calculatedzoommode", defaults, makeConnections); // pastactualsizeenabled syncCheckbox(ui->pastActualSizeCheckbox, "pastactualsizeenabled", defaults, makeConnections); // fitoverscan @@ -593,6 +593,13 @@ const QMap QVOptionsDialog::mapAfterMatchingSize }; } +const QMap QVOptionsDialog::mapCalculatedZoomMode() { + return { + { Qv::CalculatedZoomMode::ZoomToFit, tr("Zoom to Fit") }, + { Qv::CalculatedZoomMode::FillWindow, tr("Fill Window") } + }; +} + const QMap QVOptionsDialog::mapColorSpaceConversion() { return { { Qv::ColorSpaceConversion::Disabled, tr("Disabled") }, @@ -602,14 +609,6 @@ const QMap QVOptionsDialog::mapColorSpaceConv }; } -const QMap QVOptionsDialog::mapFitMode() { - return { - { Qv::FitMode::WholeImage, tr("Fit whole image") }, - { Qv::FitMode::OnlyHeight, tr("Fit height") }, - { Qv::FitMode::OnlyWidth, tr("Fit width") } - }; -} - const QMap QVOptionsDialog::mapPreloadMode() { return { { Qv::PreloadMode::Disabled, tr("Disabled") }, @@ -651,6 +650,7 @@ const QMap QVOptionsDialog::mapViewportClickAc return { { Qv::ViewportClickAction::None, tr("None") }, { Qv::ViewportClickAction::ZoomToFit, tr("Zoom to Fit") }, + { Qv::ViewportClickAction::FillWindow, tr("Fill Window") }, { Qv::ViewportClickAction::OriginalSize, tr("Original Size") }, { Qv::ViewportClickAction::ToggleFullScreen, tr("Toggle Full Screen") }, { Qv::ViewportClickAction::ToggleTitlebarHidden, tr("Toggle Titlebar Hidden") } @@ -692,7 +692,7 @@ void QVOptionsDialog::populateComboBoxes() populateComboBox(ui->afterMatchingSizeComboBox, mapAfterMatchingSize()); - populateComboBox(ui->cropModeComboBox, mapFitMode()); + populateComboBox(ui->zoomDefaultComboBox, mapCalculatedZoomMode()); populateComboBox(ui->colorSpaceConversionComboBox, mapColorSpaceConversion()); diff --git a/src/qvoptionsdialog.h b/src/qvoptionsdialog.h index 425f78f7..abe0575f 100644 --- a/src/qvoptionsdialog.h +++ b/src/qvoptionsdialog.h @@ -47,8 +47,8 @@ class QVOptionsDialog : public QDialog const QMap mapAfterDelete(); const QMap mapAfterMatchingSize(); + const QMap mapCalculatedZoomMode(); const QMap mapColorSpaceConversion(); - const QMap mapFitMode(); const QMap mapPreloadMode(); const QMap mapSortMode(); const QMap mapTitleBarText(); diff --git a/src/qvoptionsdialog.ui b/src/qvoptionsdialog.ui index d8a3f721..bb4489d0 100644 --- a/src/qvoptionsdialog.ui +++ b/src/qvoptionsdialog.ui @@ -421,17 +421,17 @@ - + Ignores select sides of an image when fitting to window (some sides will extend beyond the window boundaries) - On window resize: + Zoom default: - + Ignores select sides of an image when fitting to window (some sides will extend beyond the window boundaries) diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index 59589726..bc4af0c3 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -197,7 +197,7 @@ void SettingsManager::initializeSettingsLibrary() #else settingsLibrary.insert("onetoonepixelsizing", {true, {}}); #endif - settingsLibrary.insert("cropmode", {static_cast(Qv::FitMode::WholeImage), {}}); + settingsLibrary.insert("calculatedzoommode", {static_cast(Qv::CalculatedZoomMode::ZoomToFit), {}}); settingsLibrary.insert("pastactualsizeenabled", {true, {}}); settingsLibrary.insert("fitoverscan", {0, {}}); settingsLibrary.insert("constrainimageposition", {true, {}}); diff --git a/src/shortcutmanager.cpp b/src/shortcutmanager.cpp index 81eacde5..4936aa39 100644 --- a/src/shortcutmanager.cpp +++ b/src/shortcutmanager.cpp @@ -93,7 +93,8 @@ void ShortcutManager::initializeShortcutsList() shortcutsList.append({tr("Zoom Out"), "zoomout", keyBindingsToStringList(QKeySequence::ZoomOut), {}}); shortcutsList.append({tr("Original Size"), "originalsize", QStringList(QKeySequence(Qt::CTRL | Qt::Key_0).toString()), {}}); shortcutsList.append({tr("Zoom to Fit"), "zoomtofit", QStringList(QKeySequence(Qt::CTRL | Qt::Key_9).toString()), {}}); - shortcutsList.append({tr("Navigation Resets Zoom"), "navigationresetszoom", QStringList(QKeySequence(Qt::CTRL | Qt::Key_8).toString()), {}}); + shortcutsList.append({tr("Fill Window"), "fillwindow", QStringList(QKeySequence(Qt::CTRL | Qt::Key_8).toString()), {}}); + shortcutsList.append({tr("Navigation Resets Zoom"), "navresetszoom", QStringList(QKeySequence(Qt::Key_Z).toString()), {}}); shortcutsList.append({tr("Rotate Right"), "rotateright", QStringList(QKeySequence(Qt::Key_Up).toString()), {}}); shortcutsList.append({tr("Rotate Left"), "rotateleft", QStringList(QKeySequence(Qt::Key_Down).toString()), {}}); shortcutsList.append({tr("Mirror"), "mirror", QStringList(QKeySequence(Qt::Key_F).toString()), {}});