From 0317050fe6434918b397674d82a5cfbfaaec9297 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 19 Feb 2010 13:00:07 +0000 Subject: Enter -> tab in lineedit. --- client/widgets/lineedit.cc | 16 ++++++++++++++++ client/widgets/lineedit.h | 3 +++ 2 files changed, 19 insertions(+) (limited to 'client') diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index 49b3704..7c2558b 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -48,6 +48,8 @@ LineEdit::LineEdit(QDomNode &node, MacroWindow *macrowindow) connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed())); connect(this, SIGNAL(textEdited(QString)), this, SLOT(user_changed())); + + installEventFilter(this); // Detect keyboard input. } void LineEdit::changed() @@ -127,3 +129,17 @@ void LineEdit::setVisibility(bool visible) { setVisible(visible); } + + +#include +bool LineEdit::eventFilter(QObject *, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast(event); + if(keyEvent->key() == Qt::Key_Return) { + QKeyEvent tabevent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier); + QCoreApplication::sendEvent(this, &tabevent); + } + } + return false; +} diff --git a/client/widgets/lineedit.h b/client/widgets/lineedit.h index 5af912f..c8ba808 100644 --- a/client/widgets/lineedit.h +++ b/client/widgets/lineedit.h @@ -60,6 +60,9 @@ public slots: signals: void wasChanged(); + +private: + bool eventFilter(QObject *, QEvent *event); }; #endif/*__PRACRO_LINEEDIT_H__*/ -- cgit v1.2.3