Commit 2f1aea73 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Catch return key

parent e53af931
Pipeline #50449 canceled with stage
......@@ -46,6 +46,7 @@ public:
, mReceiver(receiver)
{
setClearButtonEnabled(true);
installEventFilter(this);
}
protected:
......@@ -57,6 +58,22 @@ protected:
QLineEdit::keyPressEvent(event);
}
bool eventFilter(QObject *obj, QEvent *event) override
{
if (obj == this) {
if (event->type() == QEvent::KeyPress) {
auto *e = static_cast<QKeyEvent *>(event);
if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
const bool stopEvent = (e->modifiers() == Qt::NoButton || e->modifiers() == Qt::KeypadModifier);
if (stopEvent) {
Q_EMIT returnPressed();
}
return true;
}
}
}
return QObject::eventFilter(obj, event);
}
private:
QWidget *const mReceiver;
......@@ -78,7 +95,7 @@ public:
void init();
EmailAddressSelectionWidget *q = nullptr;
EmailAddressSelectionWidget *const q;
QAbstractItemModel *mModel = nullptr;
QLabel *mDescriptionLabel = nullptr;
SearchLineEdit *mSearchLine = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment