2022-12-24 20:49:50 -03:00
|
|
|
// Copyright (c) 2011-2022 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 12:20:43 -03:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#ifndef BITCOIN_QT_QVALIDATEDLINEEDIT_H
|
|
|
|
#define BITCOIN_QT_QVALIDATEDLINEEDIT_H
|
2011-07-16 13:01:05 -04:00
|
|
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
2011-11-13 09:19:52 -03: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 13:01:05 -04:00
|
|
|
class QValidatedLineEdit : public QLineEdit
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-01-23 17:51:02 -03:00
|
|
|
|
2011-07-16 13:01:05 -04:00
|
|
|
public:
|
2013-11-20 11:56:51 -03:00
|
|
|
explicit QValidatedLineEdit(QWidget *parent);
|
2011-07-22 11:06:37 -04:00
|
|
|
void clear();
|
2013-11-20 11:56:51 -03:00
|
|
|
void setCheckValidator(const QValidator *v);
|
2015-11-16 06:43:36 -03:00
|
|
|
bool isValid();
|
2011-07-16 13:01:05 -04:00
|
|
|
|
|
|
|
protected:
|
2020-03-14 03:49:59 -03:00
|
|
|
void focusInEvent(QFocusEvent *evt) override;
|
|
|
|
void focusOutEvent(QFocusEvent *evt) override;
|
2011-07-16 13:01:05 -04:00
|
|
|
|
|
|
|
private:
|
2022-12-16 08:58:38 -03:00
|
|
|
bool valid{true};
|
|
|
|
const QValidator* checkValidator{nullptr};
|
2011-07-16 13:01:05 -04:00
|
|
|
|
2015-07-14 08:59:05 -03:00
|
|
|
public Q_SLOTS:
|
2020-02-12 21:03:18 -03:00
|
|
|
void setText(const QString&);
|
2011-07-16 13:01:05 -04:00
|
|
|
void setValid(bool valid);
|
2013-11-20 11:56:51 -03:00
|
|
|
void setEnabled(bool enabled);
|
2011-07-16 13:01:05 -04:00
|
|
|
|
2015-11-16 06:43:36 -03:00
|
|
|
Q_SIGNALS:
|
|
|
|
void validationDidChange(QValidatedLineEdit *validatedLineEdit);
|
2018-07-24 11:59:49 -04:00
|
|
|
|
2015-07-14 08:59:05 -03:00
|
|
|
private Q_SLOTS:
|
2011-07-16 13:01:05 -04:00
|
|
|
void markValid();
|
2013-11-20 11:56:51 -03:00
|
|
|
void checkValidity();
|
2011-07-16 13:01:05 -04:00
|
|
|
};
|
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#endif // BITCOIN_QT_QVALIDATEDLINEEDIT_H
|