]> 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 d4bc69f2f93346222c57861d5b26c4bc3157754f..7aa199c6ec1ca89acd3cbff98c247f755ae5fe95 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <QApplication>
 #include <QFormLayout>
+#include <QKeyEvent>
 #include <QLineEdit>
 
 #include "trace.h"
@@ -165,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)
@@ -263,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);