1 /*
2     SPDX-FileCopyrightText: 2012-2013 Miquel Sabaté <mikisabate@gmail.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #ifndef GH_LINEEDIT_H
8 #define GH_LINEEDIT_H
9 
10 
11 #include <QLineEdit>
12 
13 
14 namespace gh
15 {
16 
17 /**
18  * @class LineEdit
19  *
20  * This class is the Line Edit used in the gh::ProviderWidget. It's basically
21  * the same as the QLineEdit class but it emits the returnPressed() signal
22  * when the return key has been pressed. Moreover, it also implements an
23  * internal timer that emits the returnPressed signal when 0.5 seconds have
24  * passed since the user pressed a key.
25  */
26 class LineEdit : public QLineEdit
27 {
28     Q_OBJECT
29 
30 public:
31     /// Constructor.
32     explicit LineEdit(QWidget *parent = nullptr);
33 
34     /// Destructor.
35     ~LineEdit() override;
36 
37 protected:
38     /// Overridden from QLineEdit.
39     void keyPressEvent(QKeyEvent *e) override;
40 
41 private Q_SLOTS:
42     /// The timer has timed out: stop it and emit the returnPressed signal.
43     void timeOut();
44 
45 private:
46     QTimer *m_timer;
47 };
48 
49 } // End of namespace gh
50 
51 
52 #endif // GH_LINEEDIT_H
53