]> 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 4fe9628c587e19228dbf013841045c0a3c67f891..7aa199c6ec1ca89acd3cbff98c247f755ae5fe95 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <QApplication>
 #include <QFormLayout>
+#include <QKeyEvent>
 #include <QLineEdit>
 
 #include "trace.h"
@@ -40,8 +41,7 @@ namespace view {
 const QPen Trace::AxisPen(QColor(128, 128, 128, 64));
 const int Trace::LabelHitPadding = 2;
 
-Trace::Trace(pv::SigSession &session, QString name) :
-       _session(session),
+Trace::Trace(QString name) :
        _name(name),
        _v_offset(0),
        _popup(NULL),
@@ -166,7 +166,7 @@ bool Trace::pt_in_label_rect(int left, int right, const QPoint &point)
        (void)left;
 
        const QRectF label = get_label_rect(right);
-       return QRectF(
+       return enabled() && QRectF(
                QPointF(label.left() - LabelHitPadding,
                        label.top() - LabelHitPadding),
                QPointF(right, label.bottom() + LabelHitPadding)
@@ -264,6 +264,8 @@ void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
 {
        QLineEdit *const name_edit = new QLineEdit(parent);
        name_edit->setText(_name);
+       name_edit->selectAll();
+       name_edit->setFocus();
        connect(name_edit, SIGNAL(textChanged(const QString&)),
                this, SLOT(on_text_changed(const QString&)));
        form->addRow(tr("Name"), name_edit);