[LyX/master] Initialize F&R dialog with selected text (#8448)
Juergen Spitzmueller
spitz at lyx.org
Mon Feb 15 15:01:23 UTC 2021
commit c4fbd0d91344e0a8c5f7fd209b960946bec83f1f
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Mon Feb 15 16:04:17 2021 +0100
Initialize F&R dialog with selected text (#8448)
---
src/frontends/qt/GuiSearch.cpp | 8 ++++++++
src/frontends/qt/GuiSearch.h | 5 ++++-
src/frontends/qt/GuiView.cpp | 3 +++
3 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp
index 519c1c2..416b574 100644
--- a/src/frontends/qt/GuiSearch.cpp
+++ b/src/frontends/qt/GuiSearch.cpp
@@ -91,6 +91,14 @@ GuiSearchWidget::GuiSearchWidget(QWidget * parent)
}
+bool GuiSearchWidget::initialiseParams(std::string const & str)
+{
+ if (!str.empty())
+ findCO->lineEdit()->setText(toqstr(str));
+ return true;
+}
+
+
void GuiSearchWidget::keyPressEvent(QKeyEvent * ev)
{
KeySymbol sym;
diff --git a/src/frontends/qt/GuiSearch.h b/src/frontends/qt/GuiSearch.h
index ad8f9c3..e90e3dc 100644
--- a/src/frontends/qt/GuiSearch.h
+++ b/src/frontends/qt/GuiSearch.h
@@ -38,6 +38,8 @@ public:
///
void setBufferView(BufferView const * bv) { bv_ = bv; }
///
+ bool initialiseParams(std::string const &);
+ ///
bool isMinimized() { return minimized_; }
private Q_SLOTS:
@@ -85,7 +87,8 @@ public:
/// Controller inherited method.
///@{
- bool initialiseParams(std::string const &) override { return true; }
+ bool initialiseParams(std::string const & sdata) override
+ { return widget_->initialiseParams(sdata); }
void clearParams() override {}
void dispatchParams() override {}
bool isBufferDependent() const override { return true; }
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 52dc6f9..7a6a9db 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -4426,6 +4426,9 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
sdata = bv->cursor().getEncoding()->name();
if (!sdata.empty())
showDialog("symbols", sdata);
+ } else if (name == "findreplace") {
+ sdata = to_utf8(bv->cursor().selectionAsString(false));
+ showDialog(name, sdata);
// bug 5274
} else if (name == "prefs" && isFullScreen()) {
lfunUiToggle("fullscreen");
More information about the lyx-cvs
mailing list