From 01ab57dabbc15f52143089e53317bb51b71dc7f2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 8 Nov 2011 10:46:30 +0100 Subject: New lua and xml attr methods for setting widget foreground and background colours. --- client/widgets/common.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'client/widgets/common.cc') 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 #include +#include + //#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) -- cgit v1.2.3