summaryrefslogtreecommitdiff
path: root/client/widgets/textedit.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/textedit.cc')
-rw-r--r--client/widgets/textedit.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc
index d1bd6e4..9334d8a 100644
--- a/client/widgets/textedit.cc
+++ b/client/widgets/textedit.cc
@@ -26,15 +26,24 @@
*/
#include "textedit.h"
#include <stdio.h>
+#include <QPalette>
TextEdit::TextEdit(QDomNode node)
: QTextEdit(), Widget(node)
{
- setAutoFillBackground(true); /* Default is false, which disables background
- color manipulation.*/
+ //setAutoFillBackground(true); /* Default is false, which disables background
+ // color manipulation.*/
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()), this, SLOT(changed()));
@@ -53,11 +62,11 @@ void TextEdit::changed()
if(rx.exactMatch(QTextEdit::toPlainText())) {
// 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);
@@ -66,7 +75,11 @@ void TextEdit::changed()
bool TextEdit::isValid()
{
- return valid;
+ if(rx.exactMatch(QTextEdit::toPlainText())) {
+ return true;
+ } else {
+ return false;
+ }
}
QString TextEdit::getValue()