From: Soeren Apel <[email protected]>

As we're now having a generic approach to hooking into the line edits in
popups, let's 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<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();
        }
 }
 
-- 
1.7.8.6


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to