From: Richard Heck Date: Mon, 2 Apr 2018 02:18:04 +0000 (-0400) Subject: Fix bug 11099. X-Git-Tag: 2.3.1~133^2~8 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2bb9d495276b43db58c0eb1783df0cd47eac164b;p=features.git Fix bug 11099. Adds simple search/find functionality to preamble. --- diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 4020f17fa9..f5af06ede0 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -469,6 +469,29 @@ PreambleModule::PreambleModule(QWidget * parent) preambleTE->setWordWrapMode(QTextOption::NoWrap); setFocusProxy(preambleTE); connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed())); + connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton())); + connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText())); + connect(findLE, SIGNAL(returnPressed()), this, SLOT(findText())); + checkFindButton(); +} + + +void PreambleModule::checkFindButton() +{ + findButtonPB->setEnabled(!findLE->text().isEmpty()); +} + + +void PreambleModule::findText() +{ + bool const found = preambleTE->find(findLE->text()); + if (!found) { + // wrap + QTextCursor qtcur = preambleTE->textCursor(); + qtcur.movePosition(QTextCursor::Start); + preambleTE->setTextCursor(qtcur); + preambleTE->find(findLE->text()); + } } diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 1fe1dc74a1..e4f32e2570 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -332,10 +332,14 @@ private: void closeEvent(QCloseEvent *); void on_preambleTE_textChanged() { changed(); } -private: typedef std::map > Coords; Coords preamble_coords_; BufferId current_id_; + +private Q_SLOTS: + /// + void checkFindButton(); + void findText(); }; diff --git a/src/frontends/qt4/ui/PreambleUi.ui b/src/frontends/qt4/ui/PreambleUi.ui index b39f26173d..1bc1c52879 100644 --- a/src/frontends/qt4/ui/PreambleUi.ui +++ b/src/frontends/qt4/ui/PreambleUi.ui @@ -1,7 +1,8 @@ - + + PreambleUi - - + + 0 0 @@ -9,19 +10,38 @@ 278 - + - - + + 11 - + + 11 + + + 11 + + + 11 + + 6 - - - + + + + + + + Find + + + + + + false @@ -29,7 +49,7 @@ - qt_i18n.h + qt_i18n.h