]> sigrok.org Git - pulseview.git/blobdiff - pv/view/trace.cpp
Use a generic approach when adding the "close on enter" hook for popups
[pulseview.git] / pv / view / trace.cpp
index 250376ebb8828d931300a8a1a9ba5fc96ca4b749..7aa199c6ec1ca89acd3cbff98c247f755ae5fe95 100644 (file)
@@ -219,24 +219,6 @@ 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<QKeyEvent*>(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;
@@ -288,17 +270,9 @@ 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;