summaryrefslogtreecommitdiff
path: root/client/widgets/common.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-11-08 10:46:30 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2011-11-08 10:46:30 +0100
commit01ab57dabbc15f52143089e53317bb51b71dc7f2 (patch)
treea2ec194709f0d60d6162225d084340e1a7ab3cb8 /client/widgets/common.cc
parentdf2f71c7021e507bdc6ba9c11b5b02775af19561 (diff)
New lua and xml attr methods for setting widget foreground and background colours.
Diffstat (limited to 'client/widgets/common.cc')
-rw-r--r--client/widgets/common.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/client/widgets/common.cc b/client/widgets/common.cc
index 2262074..3cf0d54 100644
--- a/client/widgets/common.cc
+++ b/client/widgets/common.cc
@@ -31,6 +31,8 @@
#include <QDomElement>
#include <QString>
+#include <stdio.h>
+
//#define LINEWIDTH 80
static QString reformatHelpString(QString help)
@@ -74,6 +76,31 @@ void setCommonAttributes(QWidget *widget, QDomNode &node)
widget->setWhatsThis(helptext);
// widget->setToolTip(helptext);
}
+
+ if(elem.hasAttribute("colour") &&
+ elem.attribute("colour").length() == 6) {
+ unsigned int r, g, b;
+ sscanf(elem.attribute("colour").toStdString().c_str(),
+ "%02x%02x%02x", &r, &g, &b);
+
+ char style[128];
+ sprintf(style, "* { color: #%02x%02x%02x; }",
+ r, g, b);
+ widget->setStyleSheet(style);
+ }
+
+ if(elem.hasAttribute("bgcolour") &&
+ elem.attribute("bgcolour").length() == 6) {
+ unsigned int r, g, b;
+ sscanf(elem.attribute("bgcolour").toStdString().c_str(),
+ "%02x%02x%02x", &r, &g, &b);
+
+ char style[128];
+ sprintf(style, "* { background-color: #%02x%02x%02x; }",
+ r, g, b);
+ widget->setStyleSheet(style);
+ }
+
}
void setCommonLayout(QWidget *widget, QDomNode &node)