]> sigrok.org Git - pulseview.git/commitdiff
Generic auto-focusing for first line edit of popup
authorSoeren Apel <redacted>
Thu, 11 Sep 2014 21:11:43 +0000 (23:11 +0200)
committerUwe Hermann <redacted>
Mon, 15 Sep 2014 19:24:24 +0000 (21:24 +0200)
As there is a generic approach to hooking into the line edits
in popups, use that to also do auto-focus/auto-select-all.

pv/view/signal.cpp
pv/view/trace.cpp
pv/widgets/popup.cpp

index 51af899ee4d814d8703e92c33ebfe135142cd6ad..7df31767ea5492659dcc8e1e33ef5b0a17c9cb4c 100644 (file)
@@ -112,9 +112,6 @@ void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
                _name_widget->setCurrentIndex(index);
        }
 
-       _name_widget->lineEdit()->selectAll();
-       _name_widget->setFocus();
-
        connect(_name_widget, SIGNAL(editTextChanged(const QString&)),
                this, SLOT(on_text_changed(const QString&)));
 
index 7aa199c6ec1ca89acd3cbff98c247f755ae5fe95..f23de2ff50b33cb2771468584b8b4c5051bf3fab 100644 (file)
@@ -264,8 +264,6 @@ 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);
index 141985eb556a2e1c87ca2e558f90acd9203d7330..52701380787e8845dd7830955e526dabdd86a93b 100644 (file)
@@ -78,7 +78,7 @@ bool Popup::eventFilter(QObject *obj, QEvent *evt)
                keyEvent = static_cast<QKeyEvent*>(evt);
                if (keyEvent->key() == Qt::Key_Enter ||
                    keyEvent->key() == Qt::Key_Return) {
-                       this->close();
+                       close();
                        return true;
                }
        }
@@ -104,6 +104,9 @@ void Popup::show()
                        le->installEventFilter(this);
                else
                        le->parent()->installEventFilter(this);
+
+               le->selectAll();
+               le->setFocus();
        }
 }