lbrycrd/src/qt/qvalidatedlineedit.cpp

44 lines
751 B
C++
Raw Normal View History

2011-07-16 19:01:05 +02:00
#include "qvalidatedlineedit.h"
QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) :
QLineEdit(parent), valid(true)
{
connect(this, SIGNAL(textChanged(QString)), this, SLOT(markValid()));
}
void QValidatedLineEdit::setValid(bool valid)
{
if(valid == this->valid)
{
return;
}
if(valid)
{
setStyleSheet("");
}
else
{
setStyleSheet("background:#FF8080");
}
this->valid = valid;
}
void QValidatedLineEdit::focusInEvent(QFocusEvent *evt)
{
// Clear invalid flag on focus
setValid(true);
QLineEdit::focusInEvent(evt);
}
void QValidatedLineEdit::markValid()
{
setValid(true);
}
2011-07-22 17:06:37 +02:00
void QValidatedLineEdit::clear()
{
setValid(true);
QLineEdit::clear();
}