[gwenview/Applications/18.08] /: Add mouse shortcut for Fill and adapt docbook
Henrik Fehlauer
null at kde.org
Mon Jul 16 23:11:51 BST 2018
Git commit 11ed44cdf988db2a055265afc76f6b7c8be64fb6 by Henrik Fehlauer.
Committed on 16/07/2018 at 22:11.
Pushed by rkflx into branch 'Applications/18.08'.
Add mouse shortcut for Fill and adapt docbook
Summary:
D14093 will add back middle-clicking to toggle between {nav Fit} (with
{key F} as its keyboard shortcut) and {nav 100%} zoom. In addition,
D14094 sets {key Shift F} as a shortcut for {nav Fill}.
Going along with this, here we add {key Shift}-middle-clicking for
{nav Fill}. The code is moved to `DocumentView` in order not to
duplicate the handling of the toggling behaviour.
We also adapt the docbook accordingly, as some users still seem to read
the manual.
CCBUG: 396360
Depends on D14093
Test Plan:
Middle-click multiple times on an image in {nav View} mode and observe
{nav Fit} is toggled. Repeat while holding down {key Shift} for
{nav Fill}.
Proof-read docbook ("View mode" and "Tips" sections).
Reviewers: #gwenview, muhlenpfordt
Reviewed By: #gwenview, muhlenpfordt
Subscribers: muhlenpfordt, kde-doc-english
Tags: #documentation
Differential Revision: https://phabricator.kde.org/D14103
M +3 -4 doc/index.docbook
M +0 -8 lib/documentview/abstractimageview.cpp
M +13 -0 lib/documentview/documentview.cpp
M +1 -0 lib/documentview/documentview.h
https://commits.kde.org/gwenview/11ed44cdf988db2a055265afc76f6b7c8be64fb6
diff --git a/doc/index.docbook b/doc/index.docbook
index 9bc0fea7..367f25eb 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -36,7 +36,7 @@
</copyright>
<legalnotice>&FDLNotice;</legalnotice>
-<date>2018-04-09</date>
+<date>2018-07-13</date>
<releaseinfo>Applications 18.08</releaseinfo>
<abstract>
<para>&gwenview; is an image and video viewer.</para>
@@ -263,7 +263,7 @@ 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, 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>
+the actual pixel size. The shortcut <keycap>F</keycap> toggles between <guibutton>Fit</guibutton> mode and <guibutton>100%</guibutton>, pressing <keycombo action="simul">&Shift;<keycap>F</keycap></keycombo> will toggle <guibutton>Fill</guibutton> respectively.</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.
@@ -532,8 +532,7 @@ enter it into the text box or type one manually.</para>
<sect2 id='mouse_zooming'><title>Zooming with the mouse</title>
<itemizedlist>
- <listitem><para>Clicking the middle mouse button will toggle the auto zoom
- on/off.</para></listitem>
+ <listitem><para>Clicking the middle mouse button will toggle the <guibutton>Fit</guibutton> zoom button. Hold down the &Shift; key and middle-click to toggle the <guibutton>Fill</guibutton> zoom button.</para></listitem>
<listitem><para>Hold down the &Ctrl; key, then either use the mouse wheel to
zoom in and out or left click to zoom in and right click to zoom
out.</para></listitem>
diff --git a/lib/documentview/abstractimageview.cpp b/lib/documentview/abstractimageview.cpp
index 8119e4cc..65e45218 100644
--- a/lib/documentview/abstractimageview.cpp
+++ b/lib/documentview/abstractimageview.cpp
@@ -368,14 +368,6 @@ qreal AbstractImageView::computeZoomToFill() const
void AbstractImageView::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
QGraphicsItem::mousePressEvent(event);
- if (event->button() == Qt::MiddleButton) {
- bool value = !zoomToFit();
- setZoomToFit(value);
- if (!value) {
- setZoom(1., event->pos());
- }
- return;
- }
d->checkAndRequestZoomAction(event);
diff --git a/lib/documentview/documentview.cpp b/lib/documentview/documentview.cpp
index ffea98d2..2942282c 100644
--- a/lib/documentview/documentview.cpp
+++ b/lib/documentview/documentview.cpp
@@ -708,6 +708,19 @@ void DocumentView::resizeEvent(QGraphicsSceneResizeEvent *event)
QGraphicsWidget::resizeEvent(event);
}
+void DocumentView::mousePressEvent(QGraphicsSceneMouseEvent* event)
+{
+ QGraphicsWidget::mousePressEvent(event);
+
+ if (d->mAdapter->canZoom() && event->button() == Qt::MiddleButton) {
+ if (event->modifiers() == Qt::NoModifier) {
+ toggleZoomToFit();
+ } else if (event->modifiers() == Qt::SHIFT) {
+ toggleZoomToFill();
+ }
+ }
+}
+
void DocumentView::wheelEvent(QGraphicsSceneWheelEvent* event)
{
if (d->mAdapter->canZoom() && event->modifiers() & Qt::ControlModifier) {
diff --git a/lib/documentview/documentview.h b/lib/documentview/documentview.h
index 8e1a2b07..d044bbe7 100644
--- a/lib/documentview/documentview.h
+++ b/lib/documentview/documentview.h
@@ -204,6 +204,7 @@ protected:
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) Q_DECL_OVERRIDE;
void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
+ void mousePressEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
void wheelEvent(QGraphicsSceneWheelEvent* event) Q_DECL_OVERRIDE;
void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) Q_DECL_OVERRIDE;
bool sceneEventFilter(QGraphicsItem*, QEvent*) Q_DECL_OVERRIDE;
More information about the kde-doc-english
mailing list