2014-12-16 17:47:57 -08:00
|
|
|
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
2014-12-12 20:09:33 -08:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 07:20:43 -08:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 07:16:40 -08:00
|
|
|
#ifndef BITCOIN_QT_QVALIDATEDLINEEDIT_H
|
|
|
|
#define BITCOIN_QT_QVALIDATEDLINEEDIT_H
|
2011-07-16 10:01:05 -07:00
|
|
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
2011-11-13 04:19:52 -08:00
|
|
|
/** Line edit that can be marked as "invalid" to show input validation feedback. When marked as invalid,
|
|
|
|
it will get a red background until it is focused.
|
|
|
|
*/
|
2011-07-16 10:01:05 -07:00
|
|
|
class QValidatedLineEdit : public QLineEdit
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-01-23 12:51:02 -08:00
|
|
|
|
2011-07-16 10:01:05 -07:00
|
|
|
public:
|
2013-11-20 06:56:51 -08:00
|
|
|
explicit QValidatedLineEdit(QWidget *parent);
|
2011-07-22 08:06:37 -07:00
|
|
|
void clear();
|
2013-11-20 06:56:51 -08:00
|
|
|
void setCheckValidator(const QValidator *v);
|
2011-07-16 10:01:05 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void focusInEvent(QFocusEvent *evt);
|
2013-11-20 06:56:51 -08:00
|
|
|
void focusOutEvent(QFocusEvent *evt);
|
2011-07-16 10:01:05 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool valid;
|
2013-11-20 06:56:51 -08:00
|
|
|
const QValidator *checkValidator;
|
2011-07-16 10:01:05 -07:00
|
|
|
|
2015-07-14 04:59:05 -07:00
|
|
|
public Q_SLOTS:
|
2011-07-16 10:01:05 -07:00
|
|
|
void setValid(bool valid);
|
2013-11-20 06:56:51 -08:00
|
|
|
void setEnabled(bool enabled);
|
2011-07-16 10:01:05 -07:00
|
|
|
|
2015-07-14 04:59:05 -07:00
|
|
|
private Q_SLOTS:
|
2011-07-16 10:01:05 -07:00
|
|
|
void markValid();
|
2013-11-20 06:56:51 -08:00
|
|
|
void checkValidity();
|
2011-07-16 10:01:05 -07:00
|
|
|
};
|
|
|
|
|
2014-11-03 07:16:40 -08:00
|
|
|
#endif // BITCOIN_QT_QVALIDATEDLINEEDIT_H
|