mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Fix bug #12061.
This commit is contained in:
parent
fca8e54289
commit
62413580de
@ -481,6 +481,8 @@ PreambleModule::PreambleModule(QWidget * parent)
|
||||
preambleTE->setFont(guiApp->typewriterSystemFont());
|
||||
preambleTE->setWordWrapMode(QTextOption::NoWrap);
|
||||
setFocusProxy(preambleTE);
|
||||
// Install event filter on find line edit to capture return/enter key
|
||||
findLE->installEventFilter(this);
|
||||
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
|
||||
connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton()));
|
||||
connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText()));
|
||||
@ -499,6 +501,23 @@ PreambleModule::PreambleModule(QWidget * parent)
|
||||
}
|
||||
|
||||
|
||||
bool PreambleModule::eventFilter(QObject * sender, QEvent * event)
|
||||
{
|
||||
if (sender == findLE) {
|
||||
if (event->type()==QEvent::KeyPress) {
|
||||
QKeyEvent * key = static_cast<QKeyEvent *>(event);
|
||||
if ( (key->key()==Qt::Key_Enter) || (key->key()==Qt::Key_Return) ) {
|
||||
findText();
|
||||
// Return true to filter out the event
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(sender, event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PreambleModule::checkFindButton()
|
||||
{
|
||||
findButtonPB->setEnabled(!findLE->text().isEmpty());
|
||||
|
@ -373,6 +373,9 @@ Q_SIGNALS:
|
||||
/// signal that something's changed in the Widget.
|
||||
void changed();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject * sender, QEvent * event);
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent *) override;
|
||||
void on_preambleTE_textChanged() { changed(); }
|
||||
|
@ -30,7 +30,11 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="findLE"/>
|
||||
<widget class="QLineEdit" name="findLE">
|
||||
<property name="placeholderText">
|
||||
<string>Find in preamble</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="findButtonPB">
|
||||
|
Loading…
Reference in New Issue
Block a user