]>
Commit | Line | Data |
---|---|---|
e592d43f WL |
1 | // Copyright (c) 2011-2013 The Bitcoin developers |
2 | // Distributed under the MIT/X11 software license, see the accompanying | |
3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
4 | ||
84738627 PJ |
5 | #ifndef BITCOIN_QT_QVALIDATEDLINEEDIT_H |
6 | #define BITCOIN_QT_QVALIDATEDLINEEDIT_H | |
a5e6d723 WL |
7 | |
8 | #include <QLineEdit> | |
9 | ||
af836ad5 WL |
10 | /** Line edit that can be marked as "invalid" to show input validation feedback. When marked as invalid, |
11 | it will get a red background until it is focused. | |
12 | */ | |
a5e6d723 WL |
13 | class QValidatedLineEdit : public QLineEdit |
14 | { | |
15 | Q_OBJECT | |
32af5266 | 16 | |
a5e6d723 | 17 | public: |
c78bd937 | 18 | explicit QValidatedLineEdit(QWidget *parent); |
73cd5e52 | 19 | void clear(); |
c78bd937 | 20 | void setCheckValidator(const QValidator *v); |
a5e6d723 WL |
21 | |
22 | protected: | |
23 | void focusInEvent(QFocusEvent *evt); | |
c78bd937 | 24 | void focusOutEvent(QFocusEvent *evt); |
a5e6d723 WL |
25 | |
26 | private: | |
27 | bool valid; | |
c78bd937 | 28 | const QValidator *checkValidator; |
a5e6d723 WL |
29 | |
30 | public slots: | |
31 | void setValid(bool valid); | |
c78bd937 | 32 | void setEnabled(bool enabled); |
a5e6d723 WL |
33 | |
34 | private slots: | |
35 | void markValid(); | |
c78bd937 | 36 | void checkValidity(); |
a5e6d723 WL |
37 | }; |
38 | ||
84738627 | 39 | #endif // BITCOIN_QT_QVALIDATEDLINEEDIT_H |