diff --git a/app/viewmainpage.h b/app/viewmainpage.h --- a/app/viewmainpage.h +++ b/app/viewmainpage.h @@ -37,6 +37,7 @@ namespace Gwenview { +class AbstractRasterImageViewTool; class DocumentView; class GvCore; class RasterImageView; @@ -150,6 +151,8 @@ private: friend struct ViewMainPagePrivate; ViewMainPagePrivate* const d; + + void updateFocus(const AbstractRasterImageViewTool* tool); }; } // namespace diff --git a/app/viewmainpage.cpp b/app/viewmainpage.cpp --- a/app/viewmainpage.cpp +++ b/app/viewmainpage.cpp @@ -347,6 +347,9 @@ Q_ASSERT(mActivityResources.contains(view)); mActivityResources.value(view)->notifyFocusedIn(); + + QObject::connect(view, &DocumentView::currentToolChanged, + q, &ViewMainPage::updateFocus); } QModelIndex indexForView(DocumentView* view) const @@ -810,4 +813,11 @@ d->mDocumentViewContainer->showMessageWidget(widget, align); } +void ViewMainPage::updateFocus(const AbstractRasterImageViewTool* tool) +{ + if (!tool) { + d->mDocumentViewContainer->setFocus(); + } +} + } // namespace