GuiSearch: Properly delegate focus

This commit is contained in:
Juergen Spitzmueller 2021-02-16 13:30:31 +01:00
parent a7c1a39b5b
commit 109e98d945
3 changed files with 7 additions and 4 deletions

View File

@ -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()));

View File

@ -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;

View File

@ -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();
}
}
}