Emit editingFinished() when enter/return is pressed.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=678157
This commit is contained in:
parent
0ffa2dcc29
commit
40c39333a1
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QStyleOptionFrameV2>
|
||||
#include <QTextDocument>
|
||||
#include <QKeyEvent>
|
||||
|
||||
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"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user