From 1db1bdd6079178e218b3b1b0bd3e30efdf3e1690 Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Thu, 11 Sep 2014 23:11:43 +0200 Subject: [PATCH] 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. --- pv/view/signal.cpp | 3 --- pv/view/trace.cpp | 2 -- pv/widgets/popup.cpp | 5 ++++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 51af899..7df3176 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 7aa199c..f23de2f 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 141985e..5270138 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(); } } -- 2.30.2