From: Soeren Apel Date: Thu, 11 Sep 2014 21:11:43 +0000 (+0200) Subject: Generic auto-focusing for first line edit of popup X-Git-Tag: pulseview-0.3.0~541 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1db1bdd6079178e218b3b1b0bd3e30efdf3e1690;p=pulseview.git Generic auto-focusing for first line edit of popup As there is a generic approach to hooking into the line edits in popups, use that to also do auto-focus/auto-select-all. --- diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 51af899e..7df31767 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -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&))); diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 7aa199c6..f23de2ff 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -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); diff --git a/pv/widgets/popup.cpp b/pv/widgets/popup.cpp index 141985eb..52701380 100644 --- a/pv/widgets/popup.cpp +++ b/pv/widgets/popup.cpp @@ -78,7 +78,7 @@ bool Popup::eventFilter(QObject *obj, QEvent *evt) keyEvent = static_cast(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(); } }