diff options
Diffstat (limited to 'client/widgets/lineedit.cc')
-rw-r--r-- | client/widgets/lineedit.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index 6c3264b..cb53571 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -32,6 +32,14 @@ LineEdit::LineEdit(QDomNode node) { QDomElement elem = node.toElement(); + if(elem.hasAttribute("width")) { + resize(elem.attribute("width").toInt(), height()); + } + + if(elem.hasAttribute("height")) { + resize(width(), elem.attribute("height").toInt()); + } + if(elem.hasAttribute("regexp")) { rx = QRegExp(elem.attribute("regexp")); connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed(QString))); @@ -40,6 +48,8 @@ LineEdit::LineEdit(QDomNode node) if(elem.hasAttribute("value")) { setText(elem.attribute("value")); } else { + // This is a hack to force correct background color according to regexp + setText(" "); setText(""); } } @@ -50,20 +60,23 @@ void LineEdit::changed(QString new_text) if(rx.exactMatch(new_text)) { // valid string - palette.setBrush(backgroundRole(), QBrush(QColor(255, 255, 255))); + palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); valid = true; } else { // invalid string - palette.setBrush(backgroundRole(), QBrush(QColor(230, 200, 200))); + palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); valid = false; } setPalette(palette); - //printf("%s\n", text.toStdString().c_str()); } bool LineEdit::isValid() { - return valid; + if(rx.exactMatch(text())) { + return true; + } else { + return false; + } } QString LineEdit::getValue() |