X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Ftrace.cpp;h=250376ebb8828d931300a8a1a9ba5fc96ca4b749;hb=7db87de3cf2079f49ad395fba3a0b16f2b0f8ce5;hp=d3e7f0147b87df6adfd843ec174bca82ea96c3df;hpb=b9b7854ed5101148ba0a0d64a29708f804537a6c;p=pulseview.git diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index d3e7f01..250376e 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include "trace.h" @@ -218,6 +219,24 @@ QRectF Trace::get_label_rect(int right) label_size.width(), label_size.height()); } +bool Trace::eventFilter(QObject *obj, QEvent *evt) +{ + QKeyEvent *keyEvent; + + (void)obj; + + if (evt->type() == QEvent::KeyPress) { + keyEvent = static_cast(evt); + if (keyEvent->key() == Qt::Key_Enter || + keyEvent->key() == Qt::Key_Return) { + close_popup(); + return true; + } + } + + return false; +} + QColor Trace::get_text_colour() const { return (_colour.lightness() > 64) ? Qt::black : Qt::white; @@ -269,9 +288,17 @@ void Trace::populate_popup_form(QWidget *parent, QFormLayout *form) this, SLOT(on_text_changed(const QString&))); form->addRow(tr("Name"), name_edit); + // We want to close the popup when the Enter key was pressed. + name_edit->installEventFilter(this); + add_colour_option(parent, form); } +void Trace::close_popup() +{ + _popup->close(); +} + void Trace::on_popup_closed() { _popup = NULL;