mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
GuiSearch: catch global shortcuts to find forwards/backwards (#11170)
This commit is contained in:
parent
b1febf112d
commit
d1ea8a40af
@ -20,6 +20,9 @@
|
||||
#include "BufferView.h"
|
||||
#include "Buffer.h"
|
||||
#include "Cursor.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "KeyMap.h"
|
||||
#include "GuiKeySymbol.h"
|
||||
#include "GuiView.h"
|
||||
|
||||
#include "support/gettext.h"
|
||||
@ -30,6 +33,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
using lyx::KeySymbol;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
@ -75,6 +80,29 @@ GuiSearch::GuiSearch(GuiView & lv)
|
||||
}
|
||||
|
||||
|
||||
void GuiSearch::keyPressEvent(QKeyEvent * ev)
|
||||
{
|
||||
KeySymbol sym;
|
||||
setKeySymbol(&sym, ev);
|
||||
|
||||
// we catch the key sequences for forward and backwards search
|
||||
if (sym.isOK()) {
|
||||
KeyModifier mod = lyx::q_key_state(ev->modifiers());
|
||||
KeySequence keyseq(&theTopLevelKeymap(), &theTopLevelKeymap());
|
||||
FuncRequest fr = keyseq.addkey(sym, mod);
|
||||
if (fr == FuncRequest(LFUN_WORD_FIND_FORWARD) || fr == FuncRequest(LFUN_WORD_FIND)) {
|
||||
findClicked();
|
||||
return;
|
||||
}
|
||||
if (fr == FuncRequest(LFUN_WORD_FIND_BACKWARD)) {
|
||||
findClicked(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
QDialog::keyPressEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
void GuiSearch::showEvent(QShowEvent * e)
|
||||
{
|
||||
findChanged();
|
||||
@ -95,11 +123,11 @@ void GuiSearch::findChanged()
|
||||
}
|
||||
|
||||
|
||||
void GuiSearch::findClicked()
|
||||
void GuiSearch::findClicked(bool const backwards)
|
||||
{
|
||||
docstring const needle = qstring_to_ucs4(findCO->currentText());
|
||||
find(needle, caseCB->isChecked(), wordsCB->isChecked(),
|
||||
!backwardsCB->isChecked());
|
||||
(!backwards && !backwardsCB->isChecked()));
|
||||
uniqueInsert(findCO, findCO->currentText());
|
||||
findCO->lineEdit()->selectAll();
|
||||
}
|
||||
|
@ -28,11 +28,14 @@ public:
|
||||
|
||||
private Q_SLOTS:
|
||||
void findChanged();
|
||||
void findClicked();
|
||||
void findClicked(bool const backwards = false);
|
||||
void replaceClicked();
|
||||
void replaceallClicked();
|
||||
|
||||
private:
|
||||
///
|
||||
void keyPressEvent(QKeyEvent * e) override;
|
||||
///
|
||||
void showEvent(QShowEvent * e) override;
|
||||
///
|
||||
bool initialiseParams(std::string const &) override { return true; }
|
||||
|
Loading…
Reference in New Issue
Block a user