From 40c39333a160f9badd385a72ac946795ae48e55c Mon Sep 17 00:00:00 2001 From: Thomas Georgiou Date: Wed, 20 Jun 2007 19:49:31 +0000 Subject: [PATCH] Emit editingFinished() when enter/return is pressed. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=678157 --- widgets/lineedit.cpp | 12 ++++++++++++ widgets/lineedit.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/widgets/lineedit.cpp b/widgets/lineedit.cpp index 3c825c35a..92c935d7a 100644 --- a/widgets/lineedit.cpp +++ b/widgets/lineedit.cpp @@ -20,6 +20,7 @@ #include #include +#include namespace Plasma { @@ -130,6 +131,17 @@ QSizeF LineEdit::sizeHint() const return document()->size(); } +void LineEdit::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) + { + event->accept(); + emit editingFinished(); + } else { + QGraphicsTextItem::keyPressEvent(event); //let QT handle other keypresses + } +} + } // namespace Plasma #include "lineedit.moc" diff --git a/widgets/lineedit.h b/widgets/lineedit.h index 2b7002fe3..c5ca51f10 100644 --- a/widgets/lineedit.h +++ b/widgets/lineedit.h @@ -58,6 +58,8 @@ class PLASMA_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem void setGeometry(const QRectF& geometry); QSizeF sizeHint() const; + Q_SIGNALS: + void editingFinished(); public Q_SLOTS: void updated(const QString&, const Plasma::DataEngine::Data&); @@ -65,6 +67,9 @@ class PLASMA_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem private: class Private; Private* const d; + + protected: + void keyPressEvent(QKeyEvent* event); }; } // namespace Plasma