[LyX/master] GuiSearch: Properly delegate focus

Juergen Spitzmueller spitz at lyx.org
Tue Feb 16 12:27:19 UTC 2021


commit 109e98d9457781a11130963dc23a15eba3d9aff4
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Tue Feb 16 13:30:31 2021 +0100

    GuiSearch: Properly delegate focus
---
 src/frontends/qt/GuiSearch.cpp |    4 ++--
 src/frontends/qt/GuiSearch.h   |    4 +++-
 src/frontends/qt/GuiView.cpp   |    3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp
index 639fbf1..01f3ec8 100644
--- a/src/frontends/qt/GuiSearch.cpp
+++ b/src/frontends/qt/GuiSearch.cpp
@@ -110,7 +110,7 @@ void GuiSearchWidget::keyPressEvent(QKeyEvent * ev)
 		return;
 	}
 	if (ev->key() == Qt::Key_Escape) {
-		dispatch(FuncRequest(LFUN_DIALOG_TOGGLE, "findreplace"));
+		dispatch(FuncRequest(LFUN_DIALOG_HIDE, "findreplace"));
 		return;
 	}
 
@@ -295,7 +295,7 @@ GuiSearch::GuiSearch(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags
 {
 	setWidget(widget_);
 	widget_->setBufferView(bufferview());
-	setFocusProxy(widget_->findCO);
+	setFocusProxy(widget_);
 
 	connect(widget_, SIGNAL(needTitleBarUpdate()), this, SLOT(updateTitle()));
 	connect(widget_, SIGNAL(needSizeUpdate()), this, SLOT(updateSize()));
diff --git a/src/frontends/qt/GuiSearch.h b/src/frontends/qt/GuiSearch.h
index 2db6104..d3574b3 100644
--- a/src/frontends/qt/GuiSearch.h
+++ b/src/frontends/qt/GuiSearch.h
@@ -95,9 +95,11 @@ public:
 	void updateView() override;
 	void saveSession(QSettings & settings) const override;
 	void restoreSession() override;
-	bool wantInitialFocus() const override { return true; }
 	///@}
 
+protected:
+	bool wantInitialFocus() const override { return true; }
+
 public Q_SLOTS:
 	///
 	void onBufferViewChanged() override;
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 7a6a9db..c287889 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -4893,7 +4893,8 @@ void GuiView::doShowDialog(QString const & qname, QString const & qdata,
 				// activateWindow is needed for floating dockviews
 				dialog->asQWidget()->raise();
 				dialog->asQWidget()->activateWindow();
-				dialog->asQWidget()->setFocus();
+				if (dialog->wantInitialFocus())
+					dialog->asQWidget()->setFocus();
 			}
 		}
 	}


More information about the lyx-cvs mailing list