[graphics/gwenview] /: Allow disabling Bird's Eye View

Nate Graham null at kde.org
Mon Feb 1 17:07:11 GMT 2021


Git commit 309660296dbba2f0c7b0bd93f49a91d96029211a by Nate Graham, on behalf of Madhav Kanbur.
Committed on 01/02/2021 at 17:07.
Pushed by ngraham into branch 'master'.

Allow disabling Bird's Eye View

BUG: 426105
FIXED-IN: 21.04

Signed-off-by: Madhav Kanbur <abcdjdj at gmail.com>

M  +2    -1    app/gwenviewui.rc
M  +1    -0    app/viewmainpage.cpp
M  +4    -3    doc/index.docbook
M  +17   -1    lib/documentview/documentview.cpp
M  +1    -0    lib/documentview/documentview.h
M  +12   -1    lib/documentview/documentviewcontroller.cpp
M  +4    -0    lib/gwenviewconfig.kcfg

https://invent.kde.org/graphics/gwenview/commit/309660296dbba2f0c7b0bd93f49a91d96029211a

diff --git a/app/gwenviewui.rc b/app/gwenviewui.rc
index 299bc50b..fde730f4 100644
--- a/app/gwenviewui.rc
+++ b/app/gwenviewui.rc
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!DOCTYPE gui SYSTEM "kpartgui.dtd">
-<gui name="gwenview" version="60">
+<gui name="gwenview" version="61">
 
 <MenuBar>
     <Menu name="file" >
@@ -28,6 +28,7 @@
         <Action name="view_zoom_to_fit"/>
         <Action name="view_zoom_in"/>
         <Action name="view_zoom_out"/>
+        <Action name="view_toggle_birdeyeview"/>
         <Separator/>
         <Action name="sort_by"/>
         <Action name="thumbnail_details"/>
diff --git a/app/viewmainpage.cpp b/app/viewmainpage.cpp
index 12046977..0324d015 100644
--- a/app/viewmainpage.cpp
+++ b/app/viewmainpage.cpp
@@ -571,6 +571,7 @@ void ViewMainPage::showContextMenu()
         addActionToMenu(&menu, d->mActionCollection, "view_zoom_to_fit");
         addActionToMenu(&menu, d->mActionCollection, "view_zoom_in");
         addActionToMenu(&menu, d->mActionCollection, "view_zoom_out");
+        addActionToMenu(&menu, d->mActionCollection, "view_toggle_birdeyeview");
     }
     if (d->mCompareMode) {
         menu.addSeparator();
diff --git a/doc/index.docbook b/doc/index.docbook
index 8d244d22..abe76126 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -269,9 +269,10 @@ the actual pixel size. The shortcut <keycap>F</keycap> toggles between <guibutto
 image with the arrow keys. When you zoom in, arrow keys are used to scroll the image.
 This is very similar to the behavior provided by phones or digital cameras.</para>
 
-<para>When an image is zoomed in, a bird-eye view appears and lets you scroll
-the image using the mouse and the arrow keys. The bird-eye view automatically hides
-itself after a short delay, showing back only while zooming or scrolling.</para>
+<para>When an image is zoomed in, a bird's eye view appears and lets you scroll
+the image using the mouse and the arrow keys. The bird's eye view automatically hides
+itself after a short delay, showing back only while zooming or scrolling. The bird's eye view
+can be disabled from the right click context menu or from <menuchoice><guimenu>View</guimenu><guimenuitem>Show Bird's Eye View When Zoomed In</guimenuitem></menuchoice></para>
 
 <para>You can define what happens when going to image B after having zoomed in on an area of image A using the options in the <guilabel>Zoom mode</guilabel> group on the <guimenuitem>Image View</guimenuitem> page of the &gwenview; configuration window which can be reached using the <menuchoice><guimenu>Settings</guimenu><guimenuitem>Configure &gwenview;...</guimenuitem></menuchoice>.</para>
 
diff --git a/lib/documentview/documentview.cpp b/lib/documentview/documentview.cpp
index 7198415b..1b5ae7c9 100644
--- a/lib/documentview/documentview.cpp
+++ b/lib/documentview/documentview.cpp
@@ -562,7 +562,10 @@ void DocumentView::openUrl(const QUrl &url, const DocumentView::Setup& setup)
     } else {
         QMetaObject::invokeMethod(this, &DocumentView::finishOpenUrl, Qt::QueuedConnection);
     }
-    d->setupBirdEyeView();
+
+    if (GwenviewConfig::birdEyeViewEnabled()) {
+        d->setupBirdEyeView();
+    }
 }
 
 void DocumentView::finishOpenUrl()
@@ -670,6 +673,19 @@ void DocumentView::toggleZoomToFill() {
     }
 }
 
+void DocumentView::toggleBirdEyeView()
+{
+    if (d->mBirdEyeView) {
+       BirdEyeView* tmp = d->mBirdEyeView;
+       d->mBirdEyeView = nullptr;
+       delete tmp;
+    } else {
+        d->setupBirdEyeView();
+    }
+
+    GwenviewConfig::setBirdEyeViewEnabled(!GwenviewConfig::birdEyeViewEnabled());
+}
+
 bool DocumentView::zoomToFit() const
 {
     return d->mAdapter->zoomToFit();
diff --git a/lib/documentview/documentview.h b/lib/documentview/documentview.h
index 99c1dcf6..dcb234bc 100644
--- a/lib/documentview/documentview.h
+++ b/lib/documentview/documentview.h
@@ -149,6 +149,7 @@ public Q_SLOTS:
 
     void setZoomToFill(bool);
     void toggleZoomToFill();
+    void toggleBirdEyeView();
 
     void setPosition(const QPoint&);
 
diff --git a/lib/documentview/documentviewcontroller.cpp b/lib/documentview/documentviewcontroller.cpp
index b3b3dc6f..1bbce1e8 100644
--- a/lib/documentview/documentviewcontroller.cpp
+++ b/lib/documentview/documentviewcontroller.cpp
@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
 #include <lib/documentview/abstractrasterimageviewtool.h>
 #include <lib/slidecontainer.h>
 #include <lib/zoomwidget.h>
+#include <lib/gwenviewconfig.h>
 #include "gwenview_lib_debug.h"
 
 // KF
@@ -53,6 +54,7 @@ struct DocumentViewControllerPrivate
     QAction * mActualSizeAction;
     QAction * mZoomInAction;
     QAction * mZoomOutAction;
+    QAction * mToggleBirdEyeViewAction;
     QList<QAction *> mActions;
 
     void setupActions()
@@ -82,7 +84,14 @@ struct DocumentViewControllerPrivate
         mZoomInAction = view->addAction(KStandardAction::ZoomIn);
         mZoomOutAction = view->addAction(KStandardAction::ZoomOut);
 
-        mActions << mZoomToFitAction << mActualSizeAction << mZoomInAction << mZoomOutAction << mZoomToFillAction;
+        mToggleBirdEyeViewAction = view->addAction(QStringLiteral("view_toggle_birdeyeview"));
+        mToggleBirdEyeViewAction->setCheckable(true);
+        mToggleBirdEyeViewAction->setChecked(GwenviewConfig::birdEyeViewEnabled());
+        mToggleBirdEyeViewAction->setText(i18n("Show Bird's Eye View When Zoomed In"));
+        mToggleBirdEyeViewAction->setIcon(QIcon::fromTheme(QStringLiteral("zoom")));
+        mToggleBirdEyeViewAction->setEnabled(mView != nullptr);
+
+        mActions << mZoomToFitAction << mActualSizeAction << mZoomInAction << mZoomOutAction << mZoomToFillAction << mToggleBirdEyeViewAction;
     }
 
     void connectZoomWidget()
@@ -165,6 +174,8 @@ void DocumentViewController::setView(DocumentView* view)
     connect(d->mZoomOutAction, SIGNAL(triggered()),
             d->mView, SLOT(zoomOut()));
 
+    connect(d->mToggleBirdEyeViewAction, &QAction::triggered, d->mView, &DocumentView::toggleBirdEyeView);
+
     d->updateActions();
     updateZoomToFitActionFromView();
     updateZoomToFillActionFromView();
diff --git a/lib/gwenviewconfig.kcfg b/lib/gwenviewconfig.kcfg
index 2cb11de2..d6706e7d 100644
--- a/lib/gwenviewconfig.kcfg
+++ b/lib/gwenviewconfig.kcfg
@@ -34,6 +34,10 @@
     </group>
 
     <group name="General">
+        <entry name="BirdEyeViewEnabled" type="Bool">
+            <default>true</default>
+        </entry>
+
         <entry name="ViewBackgroundValue" type="Int">
             <default>100</default>
         </entry>


More information about the kde-doc-english mailing list