lyx_mirror/src/frontends/qt4/GuiCommandEdit.cpp
Jean-Marc Lasgouttes 7ac700920f Auto feature for minibuffer toolbar
Now the minibuffer toolbar is "auto" by default. It is opened by
command-execute (M-x) and closed when the command is executed without error.

* make lyx::dispatch return a DispatchResult struct

* there is a new MINIBUFFER type of toolbar, that can be used for this use.

* remove special handling of M-x in minnibuffer; Escape can be used instead. Fix focus in this case.

* when minibuffer toolbar is "auto", make the toolbar close itself after
  - a command has been executed without error
  - an empty command has been executed
  - the Escape key has been used

[this is actually commit fdcff02a, which was later reverted at dd61d8cf]
2015-07-15 17:41:09 +02:00

74 lines
1.1 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)
{
switch (e->key()) {
case Qt::Key_Escape:
// emit signal
escapePressed();
break;
case Qt::Key_Up:
// emit signal
upPressed();
break;
case Qt::Key_Down:
// emit signal
downPressed();
break;
default:
QLineEdit::keyPressEvent(e);
break;
}
}
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"