[gwenview] /: Replace "Fit Width" feature with "Fill"

Henrik Fehlauer null at kde.org
Wed Feb 28 09:20:39 UTC 2018


Git commit ba63c8a44f463b883c03c77c942809cd238a6594 by Henrik Fehlauer, on behalf of Silas Lenz.
Committed on 28/02/2018 at 09:16.
Pushed by rkflx into branch 'master'.

Replace "Fit Width" feature with "Fill"

Summary:
Fit width is arguably less useful than a more general Fill feature. This replaces "Fit Width" with "Fill", fitting width or height, depending on what fills the window.

FEATURE: 195579

Test Plan: Use Fill with landscape and portrait pictures with the window in landscape and portrait size.

Reviewers: #gwenview, ngraham, rkflx

Reviewed By: #gwenview, ngraham, rkflx

Subscribers: rkflx, muhlenpfordt, ngraham, #gwenview

Tags: #gwenview

Differential Revision: https://phabricator.kde.org/D10844

M  +5    -4    doc/index.docbook
M  +5    -5    lib/documentview/abstractdocumentviewadapter.h
M  +15   -13   lib/documentview/abstractimageview.cpp
M  +4    -4    lib/documentview/abstractimageview.h
M  +19   -24   lib/documentview/documentview.cpp
M  +6    -6    lib/documentview/documentview.h
M  +19   -19   lib/documentview/documentviewcontroller.cpp
M  +1    -1    lib/documentview/documentviewcontroller.h
M  +5    -5    lib/documentview/documentviewsynchronizer.cpp
M  +1    -1    lib/documentview/documentviewsynchronizer.h
M  +6    -6    lib/documentview/rasterimageview.cpp
M  +7    -7    lib/documentview/rasterimageviewadapter.cpp
M  +3    -3    lib/documentview/rasterimageviewadapter.h
M  +9    -9    lib/documentview/svgviewadapter.cpp
M  +3    -3    lib/documentview/svgviewadapter.h
M  +13   -12   lib/zoomwidget.cpp
M  +1    -1    lib/zoomwidget.h

https://commits.kde.org/gwenview/ba63c8a44f463b883c03c77c942809cd238a6594

diff --git a/doc/index.docbook b/doc/index.docbook
index 61ac18e4..4a0e7813 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -256,11 +256,12 @@ on the left, press <keycombo action="simul">&Shift;	</keycombo>.</para>
 </screenshot>
 
 <para>The slider at the bottom right controls the zoom of the image. The
-<guibutton>Fit</guibutton> button and the <guibutton>100%</guibutton>
-button are next to the zoom slider and are two preset zoom levels. The
+<guibutton>Fit</guibutton>, <guibutton>Fill</guibutton> and <guibutton>100%</guibutton>
+buttons are next to the zoom slider and are three preset zoom levels. The
 <guibutton>Fit</guibutton> button zooms the current image to fit the size
-of the window, and the <guibutton>100%</guibutton> button zooms the image to
-the actual pixel size. The shortcut <keycap>F</keycap> toggles between both view modes.</para>
+of the window, the <guibutton>Fill</guibutton> button zooms the image to fill the window 
+by fitting width or height and the <guibutton>100%</guibutton> button zooms the image to
+the actual pixel size. The shortcut <keycap>F</keycap> switches to fit mode.</para>
 
 <para>When an image is in zoom-to-fit mode, you can go to the previous and next
 image with the arrow keys. When you zoom in, arrow keys are used to scroll the image.
diff --git a/lib/documentview/abstractdocumentviewadapter.h b/lib/documentview/abstractdocumentviewadapter.h
index 13bc74ea..75c79093 100644
--- a/lib/documentview/abstractdocumentviewadapter.h
+++ b/lib/documentview/abstractdocumentviewadapter.h
@@ -92,11 +92,11 @@ public:
         return false;
     }
 
-    // Implementation must emit zoomToFitWidthChanged()
-    virtual void setZoomToFitWidth(bool)
+    // Implementation must emit zoomToFillChanged()
+    virtual void setZoomToFill(bool)
     {}
 
-    virtual bool zoomToFitWidth() const
+    virtual bool zoomToFill() const
     {
         return false;
     }
@@ -114,7 +114,7 @@ public:
         return 1.;
     }
 
-    virtual qreal computeZoomToFitWidth() const
+    virtual qreal computeZoomToFill() const
     {
         return 1.;
     }
@@ -154,7 +154,7 @@ Q_SIGNALS:
 
     void zoomToFitChanged(bool);
 
-    void zoomToFitWidthChanged(bool);
+    void zoomToFillChanged(bool);
 
     void zoomInRequested(const QPointF&);
 
diff --git a/lib/documentview/abstractimageview.cpp b/lib/documentview/abstractimageview.cpp
index 7a2501fa..370c7d40 100644
--- a/lib/documentview/abstractimageview.cpp
+++ b/lib/documentview/abstractimageview.cpp
@@ -51,7 +51,7 @@ struct AbstractImageViewPrivate
 
     qreal mZoom;
     bool mZoomToFit;
-    bool mZoomToFitWidth;
+    bool mZoomToFill;
     QPointF mImageOffset;
     QPointF mScrollPos;
     QPointF mLastDragPos;
@@ -120,7 +120,7 @@ AbstractImageView::AbstractImageView(QGraphicsItem* parent)
     d->mEnlargeSmallerImages = false;
     d->mZoom = 1;
     d->mZoomToFit = true;
-    d->mZoomToFitWidth = false;
+    d->mZoomToFill = false;
     d->mImageOffset = QPointF(0, 0);
     d->mScrollPos = QPointF(0, 0);
     setFocusPolicy(Qt::WheelFocus);
@@ -228,9 +228,9 @@ bool AbstractImageView::zoomToFit() const
     return d->mZoomToFit;
 }
 
-bool AbstractImageView::zoomToFitWidth() const
+bool AbstractImageView::zoomToFill() const
 {
-    return d->mZoomToFitWidth;
+    return d->mZoomToFill;
 }
 
 void AbstractImageView::setZoomToFit(bool on)
@@ -245,16 +245,16 @@ void AbstractImageView::setZoomToFit(bool on)
     zoomToFitChanged(d->mZoomToFit);
 }
 
-void AbstractImageView::setZoomToFitWidth(bool on)
+void AbstractImageView::setZoomToFill(bool on)
 {
-    d->mZoomToFitWidth = on;
+    d->mZoomToFill = on;
     if (on) {
-        setZoom(computeZoomToFitWidth());
+        setZoom(computeZoomToFill());
     }
     // We do not set zoom to 1 if zoomToFit is off, this is up to the code
     // calling us. It may went to zoom to some other level and/or to zoom on
     // a particular position
-    zoomToFitWidthChanged(d->mZoomToFitWidth);
+    zoomToFillChanged(d->mZoomToFill);
 }
 
 void AbstractImageView::resizeEvent(QGraphicsSceneResizeEvent* event)
@@ -270,8 +270,8 @@ void AbstractImageView::resizeEvent(QGraphicsSceneResizeEvent* event)
         } else {
             setZoom(newZoom);
         }
-    } else if (d->mZoomToFitWidth) {
-        const qreal newZoom = computeZoomToFitWidth();
+    } else if (d->mZoomToFill) {
+        const qreal newZoom = computeZoomToFill();
         if (qFuzzyCompare(zoom(), newZoom)) {
             d->adjustImageOffset(AbstractImageViewPrivate::Notify);
         } else {
@@ -299,7 +299,7 @@ qreal AbstractImageView::computeZoomToFit() const
     return fit;
 }
 
-qreal AbstractImageView::computeZoomToFitWidth() const
+qreal AbstractImageView::computeZoomToFill() const
 {
     QSizeF docSize = documentSize();
     if (docSize.isEmpty()) {
@@ -307,10 +307,12 @@ qreal AbstractImageView::computeZoomToFitWidth() const
     }
     QSizeF viewSize = boundingRect().size();
     qreal fitWidth = viewSize.width() / docSize.width();
+    qreal fitHeight = viewSize.height() / docSize.height();
+    qreal fill = qMax(fitWidth, fitHeight);
     if (!d->mEnlargeSmallerImages) {
-        fitWidth = qMin(fitWidth, qreal(1.));
+        fill = qMin(fill, qreal(1.));
     }
-    return fitWidth;
+    return fill;
 }
 
 void AbstractImageView::mousePressEvent(QGraphicsSceneMouseEvent* event)
diff --git a/lib/documentview/abstractimageview.h b/lib/documentview/abstractimageview.h
index a84433f1..e1c0e0b2 100644
--- a/lib/documentview/abstractimageview.h
+++ b/lib/documentview/abstractimageview.h
@@ -53,11 +53,11 @@ public:
 
     bool zoomToFit() const;
 
-    bool zoomToFitWidth() const;
+    bool zoomToFill() const;
 
     virtual void setZoomToFit(bool value);
 
-    virtual void setZoomToFitWidth(bool value);
+    virtual void setZoomToFill(bool value);
 
     virtual void setDocument(Document::Ptr doc);
 
@@ -65,7 +65,7 @@ public:
 
     qreal computeZoomToFit() const;
 
-    qreal computeZoomToFitWidth() const;
+    qreal computeZoomToFill() const;
 
     QSizeF documentSize() const;
 
@@ -104,7 +104,7 @@ public Q_SLOTS:
 
 Q_SIGNALS:
     void zoomToFitChanged(bool);
-    void zoomToFitWidthChanged(bool);
+    void zoomToFillChanged(bool);
     void zoomChanged(qreal);
     void zoomInRequested(const QPointF&);
     void zoomOutRequested(const QPointF&);
diff --git a/lib/documentview/documentview.cpp b/lib/documentview/documentview.cpp
index 29c6367b..b321cd29 100644
--- a/lib/documentview/documentview.cpp
+++ b/lib/documentview/documentview.cpp
@@ -119,8 +119,8 @@ struct DocumentViewPrivate
                              q, SLOT(zoomOut(QPointF)));
             QObject::connect(adapter, SIGNAL(zoomToFitChanged(bool)),
                              q, SIGNAL(zoomToFitChanged(bool)));
-            QObject::connect(adapter, SIGNAL(zoomToFitWidthChanged(bool)),
-                             q, SIGNAL(zoomToFitWidthChanged(bool)));
+            QObject::connect(adapter, SIGNAL(zoomToFillChanged(bool)),
+                             q, SIGNAL(zoomToFillChanged(bool)));
         }
         QObject::connect(adapter, SIGNAL(scrollPosChanged()),
                          q, SIGNAL(positionChanged()));
@@ -142,8 +142,8 @@ struct DocumentViewPrivate
 
         if (mSetup.valid && adapter->canZoom()) {
             adapter->setZoomToFit(mSetup.zoomToFit);
-            adapter->setZoomToFitWidth(mSetup.zoomToFitWidth);
-            if (!mSetup.zoomToFit && !mSetup.zoomToFitWidth) {
+            adapter->setZoomToFill(mSetup.zoomToFill);
+            if (!mSetup.zoomToFit && !mSetup.zoomToFill) {
                 adapter->setZoom(mSetup.zoom);
                 adapter->setScrollPos(mSetup.position);
             }
@@ -153,8 +153,8 @@ struct DocumentViewPrivate
         if (adapter->canZoom()) {
             if (adapter->zoomToFit()) {
                 q->zoomToFitChanged(true);
-            } else if (adapter->zoomToFitWidth()) {
-                q->zoomToFitWidthChanged(true);
+            } else if (adapter->zoomToFill()) {
+                q->zoomToFillChanged(true);
             } else {
                 q->zoomChanged(adapter->zoom());
             }
@@ -248,17 +248,17 @@ struct DocumentViewPrivate
         }
     }
 
-    void uncheckZoomToFitWidth()
+    void uncheckZoomToFill()
     {
-        if (mAdapter->zoomToFitWidth()) {
-            mAdapter->setZoomToFitWidth(false);
+        if (mAdapter->zoomToFill()) {
+            mAdapter->setZoomToFill(false);
         }
     }
 
     void setZoom(qreal zoom, const QPointF& center = QPointF(-1, -1))
     {
         uncheckZoomToFit();
-        uncheckZoomToFitWidth();
+        uncheckZoomToFill();
         zoom = qBound(q->minimumZoom(), zoom, MAXIMUM_ZOOM_VALUE);
         mAdapter->setZoom(zoom, center);
     }
@@ -455,12 +455,7 @@ void DocumentView::slotCompleted()
     d->hideLoadingIndicator();
     d->updateCaption();
     d->updateZoomSnapValues();
-    if (!d->mAdapter->zoomToFit()) {
-        qreal min = minimumZoom();
-        if (d->mAdapter->zoom() < min) {
-            d->mAdapter->setZoom(min);
-        }
-    } else if (!d->mAdapter->zoomToFitWidth()) {
+    if (!d->mAdapter->zoomToFit() || !d->mAdapter->zoomToFill()) {
         qreal min = minimumZoom();
         if (d->mAdapter->zoom() < min) {
             d->mAdapter->setZoom(min);
@@ -475,8 +470,8 @@ DocumentView::Setup DocumentView::setup() const
     if (d->mAdapter->canZoom()) {
         setup.valid = true;
         setup.zoomToFit = zoomToFit();
-        setup.zoomToFitWidth = zoomToFitWidth();
-        if (!setup.zoomToFit && !setup.zoomToFitWidth) {
+        setup.zoomToFill = zoomToFill();
+        if (!setup.zoomToFit && !setup.zoomToFill) {
             setup.zoom = zoom();
             setup.position = position();
         }
@@ -508,12 +503,12 @@ void DocumentView::setZoomToFit(bool on)
     d->mAdapter->setZoomToFit(on);
 }
 
-void DocumentView::setZoomToFitWidth(bool on)
+void DocumentView::setZoomToFill(bool on)
 {
-    if (on == d->mAdapter->zoomToFitWidth()) {
+    if (on == d->mAdapter->zoomToFill()) {
         return;
     }
-    d->mAdapter->setZoomToFitWidth(on);
+    d->mAdapter->setZoomToFill(on);
 }
 
 bool DocumentView::zoomToFit() const
@@ -521,15 +516,15 @@ bool DocumentView::zoomToFit() const
     return d->mAdapter->zoomToFit();
 }
 
-bool DocumentView::zoomToFitWidth() const
+bool DocumentView::zoomToFill() const
 {
-    return d->mAdapter->zoomToFitWidth();
+    return d->mAdapter->zoomToFill();
 }
 
 void DocumentView::zoomActualSize()
 {
     d->uncheckZoomToFit();
-    d->uncheckZoomToFitWidth();
+    d->uncheckZoomToFill();
     d->mAdapter->setZoom(1.);
 }
 
diff --git a/lib/documentview/documentview.h b/lib/documentview/documentview.h
index c6bac4cb..c8d1e996 100644
--- a/lib/documentview/documentview.h
+++ b/lib/documentview/documentview.h
@@ -51,7 +51,7 @@ class GWENVIEWLIB_EXPORT DocumentView : public QGraphicsWidget
     Q_OBJECT
     Q_PROPERTY(qreal zoom READ zoom WRITE setZoom NOTIFY zoomChanged)
     Q_PROPERTY(bool zoomToFit READ zoomToFit WRITE setZoomToFit NOTIFY zoomToFitChanged)
-    Q_PROPERTY(bool zoomToFitWidth READ zoomToFitWidth WRITE setZoomToFitWidth NOTIFY zoomToFitWidthChanged)
+    Q_PROPERTY(bool zoomToFill READ zoomToFill WRITE setZoomToFill NOTIFY zoomToFillChanged)
     Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
 public:
     static const int MaximumZoom;
@@ -61,12 +61,12 @@ public:
         Setup()
         : valid(false)
         , zoomToFit(true)
-        , zoomToFitWidth(false)
+        , zoomToFill(false)
         , zoom(0)
         {}
         bool valid:1;
         bool zoomToFit:1;
-        bool zoomToFitWidth:1;
+        bool zoomToFill:1;
         qreal zoom;
         QPointF position;
     };
@@ -112,7 +112,7 @@ public:
 
     bool zoomToFit() const;
 
-    bool zoomToFitWidth() const;
+    bool zoomToFill() const;
 
     QPoint position() const;
 
@@ -147,7 +147,7 @@ public Q_SLOTS:
 
     void setZoomToFit(bool);
 
-    void setZoomToFitWidth(bool);
+    void setZoomToFill(bool);
 
     void setPosition(const QPoint&);
 
@@ -179,7 +179,7 @@ Q_SIGNALS:
 
     void zoomToFitChanged(bool);
 
-    void zoomToFitWidthChanged(bool);
+    void zoomToFillChanged(bool);
 
     void positionChanged();
 
diff --git a/lib/documentview/documentviewcontroller.cpp b/lib/documentview/documentviewcontroller.cpp
index baf2d222..4f17041b 100644
--- a/lib/documentview/documentviewcontroller.cpp
+++ b/lib/documentview/documentviewcontroller.cpp
@@ -79,7 +79,7 @@ struct DocumentViewControllerPrivate
     ToolContainerContent* mToolContainerContent;
 
     QAction * mZoomToFitAction;
-    QAction * mZoomToFitWidthAction;
+    QAction * mZoomToFillAction;
     QAction * mActualSizeAction;
     QAction * mZoomInAction;
     QAction * mZoomOutAction;
@@ -93,28 +93,28 @@ struct DocumentViewControllerPrivate
         view->collection()->setDefaultShortcut(mZoomToFitAction, Qt::Key_F);
         mZoomToFitAction->setCheckable(true);
         mZoomToFitAction->setChecked(true);
-        mZoomToFitAction->setText(i18n("Zoom to Fit"));
+        mZoomToFitAction->setText(i18n("Zoom to fit"));
         mZoomToFitAction->setIcon(QIcon::fromTheme("zoom-fit-best"));
         mZoomToFitAction->setIconText(i18nc("@action:button Zoom to fit, shown in status bar, keep it short please", "Fit"));
 
-        mZoomToFitWidthAction = view->addAction("view_zoom_to_fit_width");
-        //view->collection()->setDefaultShortcuts(mZoomToFitWidthAction, Qt::Key_W); ??
-        mZoomToFitWidthAction->setCheckable(true);
-        mZoomToFitWidthAction->setChecked(false);
-        mZoomToFitWidthAction->setText(i18n("Zoom to Fit Width"));
-        mZoomToFitWidthAction->setIcon(QIcon::fromTheme("zoom-fit-best"));
-        mZoomToFitWidthAction->setIconText(i18nc("@action:button Zoom to fit width, shown in status bar, keep it short please", "Fit Width"));
+        mZoomToFillAction = view->addAction("view_zoom_to_fill");
+        //view->collection()->setDefaultShortcuts(mZoomToFillAction, Qt::Key_W); ??
+        mZoomToFillAction->setCheckable(true);
+        mZoomToFillAction->setChecked(false);
+        mZoomToFillAction->setText(i18n("Zoom to fill window by fitting to width or height"));
+        mZoomToFillAction->setIcon(QIcon::fromTheme("zoom-fit-best"));
+        mZoomToFillAction->setIconText(i18nc("@action:button Zoom to fill (fit width or height), shown in status bar, keep it short please", "Fill"));
 
         mActualSizeAction = view->addAction(KStandardAction::ActualSize);
         mActualSizeAction->setCheckable(true);
-        mZoomToFitWidthAction->setChecked(false);
+        mZoomToFillAction->setChecked(false);
         mActualSizeAction->setIcon(QIcon::fromTheme("zoom-original"));
         mActualSizeAction->setIconText(i18nc("@action:button Zoom to original size, shown in status bar, keep it short please", "100%"));
 
         mZoomInAction = view->addAction(KStandardAction::ZoomIn);
         mZoomOutAction = view->addAction(KStandardAction::ZoomOut);
 
-        mActions << mZoomToFitAction << mActualSizeAction << mZoomInAction << mZoomOutAction << mZoomToFitWidthAction;
+        mActions << mZoomToFitAction << mActualSizeAction << mZoomInAction << mZoomOutAction << mZoomToFillAction;
     }
 
     void connectZoomWidget()
@@ -186,13 +186,13 @@ void DocumentViewController::setView(DocumentView* view)
     }
     connect(d->mView, &DocumentView::adapterChanged, this, &DocumentViewController::slotAdapterChanged);
     connect(d->mView, &DocumentView::zoomToFitChanged, this, &DocumentViewController::updateZoomToFitActionFromView);
-    connect(d->mView, &DocumentView::zoomToFitWidthChanged, this, &DocumentViewController::updateZoomToFitWidthActionFromView);
+    connect(d->mView, &DocumentView::zoomToFillChanged, this, &DocumentViewController::updateZoomToFillActionFromView);
     connect(d->mView, &DocumentView::currentToolChanged, this, &DocumentViewController::updateTool);
 
     connect(d->mZoomToFitAction, SIGNAL(toggled(bool)),
             d->mView, SLOT(setZoomToFit(bool)));
-    connect(d->mZoomToFitWidthAction, SIGNAL(toggled(bool)),
-            d->mView, SLOT(setZoomToFitWidth(bool)));
+    connect(d->mZoomToFillAction, SIGNAL(toggled(bool)),
+            d->mView, SLOT(setZoomToFill(bool)));
     connect(d->mActualSizeAction, SIGNAL(triggered()),
             d->mView, SLOT(zoomActualSize()));
     connect(d->mZoomInAction, SIGNAL(triggered()),
@@ -202,7 +202,7 @@ void DocumentViewController::setView(DocumentView* view)
 
     d->updateActions();
     updateZoomToFitActionFromView();
-    updateZoomToFitWidthActionFromView();
+    updateZoomToFillActionFromView();
     updateTool();
 
     // Sync zoom widget
@@ -224,7 +224,7 @@ void DocumentViewController::setZoomWidget(ZoomWidget* widget)
         d->mActualSizeAction,
         d->mZoomInAction,
         d->mZoomOutAction,
-        d->mZoomToFitWidthAction
+        d->mZoomToFillAction
     );
 
     d->mZoomWidget->setMaximumZoom(qreal(DocumentView::MaximumZoom));
@@ -250,10 +250,10 @@ void DocumentViewController::updateZoomToFitActionFromView()
     d->mZoomToFitAction->setChecked(d->mView->zoomToFit());
 }
 
-void DocumentViewController::updateZoomToFitWidthActionFromView()
+void DocumentViewController::updateZoomToFillActionFromView()
 {
-    SignalBlocker blocker(d->mZoomToFitWidthAction);
-    d->mZoomToFitWidthAction->setChecked(d->mView->zoomToFitWidth());
+    SignalBlocker blocker(d->mZoomToFillAction);
+    d->mZoomToFillAction->setChecked(d->mView->zoomToFill());
 }
 
 void DocumentViewController::updateTool()
diff --git a/lib/documentview/documentviewcontroller.h b/lib/documentview/documentviewcontroller.h
index c12f294d..2a9b4a9e 100644
--- a/lib/documentview/documentviewcontroller.h
+++ b/lib/documentview/documentviewcontroller.h
@@ -63,7 +63,7 @@ public:
 private Q_SLOTS:
     void slotAdapterChanged();
     void updateZoomToFitActionFromView();
-    void updateZoomToFitWidthActionFromView();
+    void updateZoomToFillActionFromView();
     void updateTool();
 
 private:
diff --git a/lib/documentview/documentviewsynchronizer.cpp b/lib/documentview/documentviewsynchronizer.cpp
index cea6391d..7f780e12 100644
--- a/lib/documentview/documentviewsynchronizer.cpp
+++ b/lib/documentview/documentviewsynchronizer.cpp
@@ -54,8 +54,8 @@ struct DocumentViewSynchronizerPrivate
                          q, SLOT(setZoom(qreal)));
         QObject::connect(mCurrentView.data(), SIGNAL(zoomToFitChanged(bool)),
                          q, SLOT(setZoomToFit(bool)));
-        QObject::connect(mCurrentView.data(), SIGNAL(zoomToFitWidthChanged(bool)),
-                         q, SLOT(setZoomToFitWidth(bool)));
+        QObject::connect(mCurrentView.data(), SIGNAL(zoomToFillChanged(bool)),
+                         q, SLOT(setZoomToFill(bool)));
         QObject::connect(mCurrentView.data(), SIGNAL(positionChanged()),
                          q, SLOT(updatePosition()));
 
@@ -65,7 +65,7 @@ struct DocumentViewSynchronizerPrivate
             }
             view->setZoom(mCurrentView.data()->zoom());
             view->setZoomToFit(mCurrentView.data()->zoomToFit());
-            view->setZoomToFitWidth(mCurrentView.data()->zoomToFitWidth());
+            view->setZoomToFill(mCurrentView.data()->zoomToFill());
         }
     }
 
@@ -130,13 +130,13 @@ void DocumentViewSynchronizer::setZoomToFit(bool fit)
     d->updateOldPosition();
 }
 
-void DocumentViewSynchronizer::setZoomToFitWidth(bool fit)
+void DocumentViewSynchronizer::setZoomToFill(bool fit)
 {
     Q_FOREACH(DocumentView* view, *d->mViews) {
         if (view == d->mCurrentView.data()) {
             continue;
         }
-        view->setZoomToFitWidth(fit);
+        view->setZoomToFill(fit);
     }
     d->updateOldPosition();
 }
diff --git a/lib/documentview/documentviewsynchronizer.h b/lib/documentview/documentviewsynchronizer.h
index 291318f1..9eb92901 100644
--- a/lib/documentview/documentviewsynchronizer.h
+++ b/lib/documentview/documentviewsynchronizer.h
@@ -57,7 +57,7 @@ public Q_SLOTS:
 private Q_SLOTS:
     void setZoom(qreal zoom);
     void setZoomToFit(bool);
-    void setZoomToFitWidth(bool);
+    void setZoomToFill(bool);
     void updatePosition();
 
 private:
diff --git a/lib/documentview/rasterimageview.cpp b/lib/documentview/rasterimageview.cpp
index ec6efb42..d3f28e45 100644
--- a/lib/documentview/rasterimageview.cpp
+++ b/lib/documentview/rasterimageview.cpp
@@ -292,8 +292,8 @@ void RasterImageView::finishSetDocument()
         // Force the update otherwise if computeZoomToFit() returns 1, setZoom()
         // will think zoom has not changed and won't update the image
         setZoom(computeZoomToFit(), QPointF(-1, -1), ForceUpdate);
-    } else if (zoomToFitWidth()) {
-        setZoom(computeZoomToFitWidth(), QPointF(-1, -1), ForceUpdate);
+    } else if (zoomToFill()) {
+        setZoom(computeZoomToFill(), QPointF(-1, -1), ForceUpdate);
     } else {
         updateBuffer();
     }
@@ -311,8 +311,8 @@ void RasterImageView::updateImageRect(const QRect& imageRect)
 
     if (zoomToFit()) {
         setZoom(computeZoomToFit());
-    } else if (zoomToFitWidth()) {
-        setZoom(computeZoomToFitWidth());
+    } else if (zoomToFill()) {
+        setZoom(computeZoomToFill());
     }
 
     d->setScalerRegionToVisibleRect();
@@ -437,7 +437,7 @@ void RasterImageView::resizeEvent(QGraphicsSceneResizeEvent* event)
     // will trigger an immediate update unless the mUpdateTimer is active.
     if (zoomToFit() && !d->mBufferIsEmpty) {
         d->mUpdateTimer->start();
-    } else if (zoomToFitWidth() && !d->mBufferIsEmpty) {
+    } else if (zoomToFill() && !d->mBufferIsEmpty) {
         d->mUpdateTimer->start();
     }
     AbstractImageView::resizeEvent(event);
@@ -445,7 +445,7 @@ void RasterImageView::resizeEvent(QGraphicsSceneResizeEvent* event)
         // Only update buffer if we are not in zoomToFit mode: if we are
         // onZoomChanged() will have already updated the buffer.
         updateBuffer();
-    } else if (!zoomToFitWidth()) {
+    } else if (!zoomToFill()) {
         updateBuffer();
     }
 }
diff --git a/lib/documentview/rasterimageviewadapter.cpp b/lib/documentview/rasterimageviewadapter.cpp
index d0e66cc7..d2154db9 100644
--- a/lib/documentview/rasterimageviewadapter.cpp
+++ b/lib/documentview/rasterimageviewadapter.cpp
@@ -48,7 +48,7 @@ RasterImageViewAdapter::RasterImageViewAdapter()
     d->mView = new RasterImageView;
     connect(d->mView, &RasterImageView::zoomChanged, this, &RasterImageViewAdapter::zoomChanged);
     connect(d->mView, &RasterImageView::zoomToFitChanged, this, &RasterImageViewAdapter::zoomToFitChanged);
-    connect(d->mView, &RasterImageView::zoomToFitWidthChanged, this, &RasterImageViewAdapter::zoomToFitWidthChanged);
+    connect(d->mView, &RasterImageView::zoomToFillChanged, this, &RasterImageViewAdapter::zoomToFillChanged);
     connect(d->mView, &RasterImageView::zoomInRequested, this, &RasterImageViewAdapter::zoomInRequested);
     connect(d->mView, &RasterImageView::zoomOutRequested, this, &RasterImageViewAdapter::zoomOutRequested);
     connect(d->mView, &RasterImageView::scrollPosChanged, this, &RasterImageViewAdapter::scrollPosChanged);
@@ -94,9 +94,9 @@ void RasterImageViewAdapter::setZoomToFit(bool on)
     d->mView->setZoomToFit(on);
 }
 
-void RasterImageViewAdapter::setZoomToFitWidth(bool on)
+void RasterImageViewAdapter::setZoomToFill(bool on)
 {
-    d->mView->setZoomToFitWidth(on);
+    d->mView->setZoomToFill(on);
 }
 
 bool RasterImageViewAdapter::zoomToFit() const
@@ -104,9 +104,9 @@ bool RasterImageViewAdapter::zoomToFit() const
     return d->mView->zoomToFit();
 }
 
-bool RasterImageViewAdapter::zoomToFitWidth() const
+bool RasterImageViewAdapter::zoomToFill() const
 {
-    return d->mView->zoomToFitWidth();
+    return d->mView->zoomToFill();
 }
 
 void RasterImageViewAdapter::setZoom(qreal zoom, const QPointF& center)
@@ -119,9 +119,9 @@ qreal RasterImageViewAdapter::computeZoomToFit() const
     return d->mView->computeZoomToFit();
 }
 
-qreal RasterImageViewAdapter::computeZoomToFitWidth() const
+qreal RasterImageViewAdapter::computeZoomToFill() const
 {
-    return d->mView->computeZoomToFitWidth();
+    return d->mView->computeZoomToFill();
 }
 
 Document::Ptr RasterImageViewAdapter::document() const
diff --git a/lib/documentview/rasterimageviewadapter.h b/lib/documentview/rasterimageviewadapter.h
index 1c5a2714..36943a41 100644
--- a/lib/documentview/rasterimageviewadapter.h
+++ b/lib/documentview/rasterimageviewadapter.h
@@ -57,11 +57,11 @@ public:
 
     virtual void setZoomToFit(bool) Q_DECL_OVERRIDE;
 
-    virtual void setZoomToFitWidth(bool) Q_DECL_OVERRIDE;
+    virtual void setZoomToFill(bool) Q_DECL_OVERRIDE;
 
     virtual bool zoomToFit() const Q_DECL_OVERRIDE;
 
-    virtual bool zoomToFitWidth() const Q_DECL_OVERRIDE;
+    virtual bool zoomToFill() const Q_DECL_OVERRIDE;
 
     virtual qreal zoom() const Q_DECL_OVERRIDE;
 
@@ -69,7 +69,7 @@ public:
 
     virtual qreal computeZoomToFit() const Q_DECL_OVERRIDE;
 
-    virtual qreal computeZoomToFitWidth() const Q_DECL_OVERRIDE;
+    virtual qreal computeZoomToFill() const Q_DECL_OVERRIDE;
 
     virtual Document::Ptr document() const Q_DECL_OVERRIDE;
 
diff --git a/lib/documentview/svgviewadapter.cpp b/lib/documentview/svgviewadapter.cpp
index 73950849..e1315b25 100644
--- a/lib/documentview/svgviewadapter.cpp
+++ b/lib/documentview/svgviewadapter.cpp
@@ -66,8 +66,8 @@ void SvgImageView::finishLoadFromDocument()
     mSvgItem->setSharedRenderer(renderer);
     if (zoomToFit()) {
         setZoom(computeZoomToFit(), QPointF(-1, -1), ForceUpdate);
-    } else if (zoomToFitWidth()) {
-        setZoom(computeZoomToFitWidth(), QPointF(-1, -1), ForceUpdate);
+    } else if (zoomToFill()) {
+        setZoom(computeZoomToFill(), QPointF(-1, -1), ForceUpdate);
     } else {
         mSvgItem->setScale(zoom());
     }
@@ -109,7 +109,7 @@ SvgViewAdapter::SvgViewAdapter()
     setWidget(d->mView);
     connect(d->mView, &SvgImageView::zoomChanged, this, &SvgViewAdapter::zoomChanged);
     connect(d->mView, &SvgImageView::zoomToFitChanged, this, &SvgViewAdapter::zoomToFitChanged);
-    connect(d->mView, &SvgImageView::zoomToFitWidthChanged, this, &SvgViewAdapter::zoomToFitWidthChanged);
+    connect(d->mView, &SvgImageView::zoomToFillChanged, this, &SvgViewAdapter::zoomToFillChanged);
     connect(d->mView, &SvgImageView::zoomInRequested, this, &SvgViewAdapter::zoomInRequested);
     connect(d->mView, &SvgImageView::zoomOutRequested, this, &SvgViewAdapter::zoomOutRequested);
     connect(d->mView, &SvgImageView::scrollPosChanged, this, &SvgViewAdapter::scrollPosChanged);
@@ -149,9 +149,9 @@ void SvgViewAdapter::setZoomToFit(bool on)
     d->mView->setZoomToFit(on);
 }
 
-void SvgViewAdapter::setZoomToFitWidth(bool on)
+void SvgViewAdapter::setZoomToFill(bool on)
 {
-    d->mView->setZoomToFitWidth(on);
+    d->mView->setZoomToFill(on);
 }
 
 bool SvgViewAdapter::zoomToFit() const
@@ -159,9 +159,9 @@ bool SvgViewAdapter::zoomToFit() const
     return d->mView->zoomToFit();
 }
 
-bool SvgViewAdapter::zoomToFitWidth() const
+bool SvgViewAdapter::zoomToFill() const
 {
-    return d->mView->zoomToFitWidth();
+    return d->mView->zoomToFill();
 }
 
 qreal SvgViewAdapter::zoom() const
@@ -179,9 +179,9 @@ qreal SvgViewAdapter::computeZoomToFit() const
     return d->mView->computeZoomToFit();
 }
 
-qreal SvgViewAdapter::computeZoomToFitWidth() const
+qreal SvgViewAdapter::computeZoomToFill() const
 {
-    return d->mView->computeZoomToFitWidth();
+    return d->mView->computeZoomToFill();
 }
 
 QPointF SvgViewAdapter::scrollPos() const
diff --git a/lib/documentview/svgviewadapter.h b/lib/documentview/svgviewadapter.h
index 695cdc18..8ec7a223 100644
--- a/lib/documentview/svgviewadapter.h
+++ b/lib/documentview/svgviewadapter.h
@@ -85,11 +85,11 @@ public:
 
     virtual void setZoomToFit(bool) Q_DECL_OVERRIDE;
 
-    virtual void setZoomToFitWidth(bool) Q_DECL_OVERRIDE;
+    virtual void setZoomToFill(bool) Q_DECL_OVERRIDE;
 
     virtual bool zoomToFit() const Q_DECL_OVERRIDE;
 
-    virtual bool zoomToFitWidth() const Q_DECL_OVERRIDE;
+    virtual bool zoomToFill() const Q_DECL_OVERRIDE;
 
     virtual qreal zoom() const Q_DECL_OVERRIDE;
 
@@ -97,7 +97,7 @@ public:
 
     virtual qreal computeZoomToFit() const Q_DECL_OVERRIDE;
 
-    virtual qreal computeZoomToFitWidth() const Q_DECL_OVERRIDE;
+    virtual qreal computeZoomToFill() const Q_DECL_OVERRIDE;
 
     virtual QPointF scrollPos() const Q_DECL_OVERRIDE;
     virtual void setScrollPos(const QPointF& pos) Q_DECL_OVERRIDE;
diff --git a/lib/zoomwidget.cpp b/lib/zoomwidget.cpp
index 9aca642b..6b9102f0 100644
--- a/lib/zoomwidget.cpp
+++ b/lib/zoomwidget.cpp
@@ -60,12 +60,12 @@ struct ZoomWidgetPrivate
 
     StatusBarToolButton* mZoomToFitButton;
     StatusBarToolButton* mActualSizeButton;
-    StatusBarToolButton* mZoomToFitWidthButton;
+    StatusBarToolButton* mZoomToFillButton;
     QLabel* mZoomLabel;
     ZoomSlider* mZoomSlider;
     QAction* mZoomToFitAction;
     QAction* mActualSizeAction;
-    QAction* mZoomToFitWidthAction;
+    QAction* mZoomToFillAction;
 
     bool mZoomUpdatedBySlider;
 
@@ -92,19 +92,19 @@ ZoomWidget::ZoomWidget(QWidget* parent)
 
     d->mZoomToFitButton = new StatusBarToolButton;
     d->mActualSizeButton = new StatusBarToolButton;
-    d->mZoomToFitWidthButton = new StatusBarToolButton;
+    d->mZoomToFillButton = new StatusBarToolButton;
     d->mZoomToFitButton->setCheckable(true);
     d->mActualSizeButton->setCheckable(true);
-    d->mZoomToFitWidthButton->setCheckable(true);
+    d->mZoomToFillButton->setCheckable(true);
     d->mZoomToFitButton->setChecked(true);
 
     if (QApplication::isLeftToRight()) {
         d->mZoomToFitButton->setGroupPosition(StatusBarToolButton::GroupLeft);
-        d->mZoomToFitWidthButton->setGroupPosition(StatusBarToolButton::GroupCenter);
+        d->mZoomToFillButton->setGroupPosition(StatusBarToolButton::GroupCenter);
         d->mActualSizeButton->setGroupPosition(StatusBarToolButton::GroupRight);
     } else {
         d->mActualSizeButton->setGroupPosition(StatusBarToolButton::GroupLeft);
-        d->mZoomToFitWidthButton->setGroupPosition(StatusBarToolButton::GroupCenter);
+        d->mZoomToFillButton->setGroupPosition(StatusBarToolButton::GroupCenter);
         d->mZoomToFitButton->setGroupPosition(StatusBarToolButton::GroupRight);
     }
 
@@ -123,7 +123,7 @@ ZoomWidget::ZoomWidget(QWidget* parent)
     layout->setMargin(0);
     layout->setSpacing(0);
     layout->addWidget(d->mZoomToFitButton);
-    layout->addWidget(d->mZoomToFitWidthButton);
+    layout->addWidget(d->mZoomToFillButton);
     layout->addWidget(d->mActualSizeButton);
     layout->addWidget(d->mZoomSlider);
     layout->addWidget(d->mZoomLabel);
@@ -134,29 +134,30 @@ ZoomWidget::~ZoomWidget()
     delete d;
 }
 
-void ZoomWidget::setActions(QAction* zoomToFitAction, QAction* actualSizeAction, QAction* zoomInAction, QAction* zoomOutAction, QAction* zoomToFitWidthAction)
+void ZoomWidget::setActions(QAction* zoomToFitAction, QAction* actualSizeAction, QAction* zoomInAction, QAction* zoomOutAction, QAction* zoomToFillAction)
 {
     d->mZoomToFitAction = zoomToFitAction;
     d->mActualSizeAction = actualSizeAction;
-    d->mZoomToFitWidthAction = zoomToFitWidthAction;
+    d->mZoomToFillAction = zoomToFillAction;
 
     d->mZoomToFitButton->setDefaultAction(zoomToFitAction);
     d->mActualSizeButton->setDefaultAction(actualSizeAction);
-    d->mZoomToFitWidthButton->setDefaultAction(zoomToFitWidthAction);
+    d->mZoomToFillButton->setDefaultAction(zoomToFillAction);
 
     d->mZoomSlider->setZoomInAction(zoomInAction);
     d->mZoomSlider->setZoomOutAction(zoomOutAction);
 
     QActionGroup *actionGroup = new QActionGroup(d->q);
     actionGroup->addAction(d->mZoomToFitAction);
-    actionGroup->addAction(d->mZoomToFitWidthAction);
+    actionGroup->addAction(d->mZoomToFillAction);
     actionGroup->addAction(d->mActualSizeAction);
     actionGroup->setExclusive(true);
 
     // Adjust sizes
-    int width = qMax(d->mZoomToFitButton->sizeHint().width(), d->mActualSizeButton->sizeHint().width());
+    int width = std::max({d->mZoomToFitButton->sizeHint().width(), d->mActualSizeButton->sizeHint().width(), d->mZoomToFillButton->sizeHint().width()});
     d->mZoomToFitButton->setFixedWidth(width);
     d->mActualSizeButton->setFixedWidth(width);
+    d->mZoomToFillButton->setFixedWidth(width);
 }
 
 void ZoomWidget::slotZoomSliderActionTriggered()
diff --git a/lib/zoomwidget.h b/lib/zoomwidget.h
index 7bdceb0b..535614cf 100644
--- a/lib/zoomwidget.h
+++ b/lib/zoomwidget.h
@@ -43,7 +43,7 @@ public:
     ZoomWidget(QWidget* parent = 0);
     ~ZoomWidget();
 
-    void setActions(QAction* zoomToFitAction, QAction* actualSizeAction, QAction* zoomInAction, QAction* zoomOutAction, QAction* zoomToFitWidthAction);
+    void setActions(QAction* zoomToFitAction, QAction* actualSizeAction, QAction* zoomInAction, QAction* zoomOutAction, QAction* zoomToFillAction);
 
 public Q_SLOTS:
     void setZoom(qreal zoom);


More information about the kde-doc-english mailing list