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 <QStyleOptionFrameV2>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -130,6 +131,17 @@ QSizeF LineEdit::sizeHint() const
|
|||||||
return document()->size();
|
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
|
} // namespace Plasma
|
||||||
|
|
||||||
#include "lineedit.moc"
|
#include "lineedit.moc"
|
||||||
|
@ -58,6 +58,8 @@ class PLASMA_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem
|
|||||||
void setGeometry(const QRectF& geometry);
|
void setGeometry(const QRectF& geometry);
|
||||||
QSizeF sizeHint() const;
|
QSizeF sizeHint() const;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void editingFinished();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void updated(const QString&, const Plasma::DataEngine::Data&);
|
void updated(const QString&, const Plasma::DataEngine::Data&);
|
||||||
@ -65,6 +67,9 @@ class PLASMA_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem
|
|||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
Private* const d;
|
Private* const d;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent* event);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
Loading…
Reference in New Issue
Block a user