lyx_mirror/src/frontends/qt/GuiCommandEdit.cpp
Daniel Ramoeller 89394bcd0f Show suggestions containing the input in the command buffer
Previously, only the suggestions starting with the current input were
shown.

Contains the following minor improvements:
- Add space to indicate when only one suggestion is found

- Select first item in suggestion-list in order to make selecting with
  arrow keys more intuitive

- Fix selection with Shift+Up/Down in text-field

Fix for bug #12572.
2022-11-04 22:27:31 +01:00

77 lines
1.2 KiB
C++

/**
* \file GuiCommandEdit.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "GuiCommandEdit.h"
#include <QKeyEvent>
#include <QEvent>
#undef KeyPress
namespace lyx {
namespace frontend {
GuiCommandEdit::GuiCommandEdit(QWidget * parent)
: QLineEdit(parent)
{
setFocusPolicy(Qt::ClickFocus);
}
void GuiCommandEdit::keyPressEvent(QKeyEvent * e)
{
if (e->modifiers() == Qt::NoModifier) {
switch (e->key()) {
case Qt::Key_Escape:
// emit signal
escapePressed();
return;
case Qt::Key_Up:
// emit signal
upPressed();
return;
case Qt::Key_Down:
// emit signal
downPressed();
return;
default:
// do nothing
break;
}
}
QLineEdit::keyPressEvent(e);
}
bool GuiCommandEdit::event(QEvent * e)
{
if (e->type() != QEvent::KeyPress)
return QLineEdit::event(e);
QKeyEvent * ev = (QKeyEvent *)e;
if (ev->key() != Qt::Key_Tab)
return QLineEdit::event(e);
// emit signal
tabPressed();
return true;
}
} // namespace frontend
} // namespace lyx
#include "moc_GuiCommandEdit.cpp"