Change output color per label
authorRalf Jung <post@ralfj.de>
Wed, 17 Jul 2013 11:59:34 +0000 (13:59 +0200)
committerRalf Jung <post@ralfj.de>
Wed, 17 Jul 2013 11:59:34 +0000 (13:59 +0200)
qt/multypo.cpp

index 2584c0c7b1f7bca5635214db1eabf26ab2d9dab2..e7a188638008266ef5112d501bfd1d46024cdc27 100644 (file)
@@ -9,12 +9,19 @@
 #include <X11/extensions/XInput2.h>
 #include <X11/Xutil.h>
 
+static QString colorToString(QColor col)
+{
+       return QString("#%1%2%3").arg(col.red(), 2, 16, QChar('0'))
+                       .arg(col.green(), 2, 16, QChar('0'))
+                       .arg(col.blue(), 2, 16, QChar('0'));
+}
+
 MultypoWindow::MultypoWindow(QWidget *parent) :
        QWidget(parent),
        xiInited(false)
 {
        /* Prepare colors */
-       setStyleSheet("background-color: black; color: green");
+       setStyleSheet("background-color: black; color: green; font-size: 30pt");
 
        /* Prepare conents */
        setLayout(new QVBoxLayout(this));
@@ -43,7 +50,8 @@ void MultypoWindow::handleKeyPress(int device, QString string)
                layout()->addWidget(label);
                players[device] = label;
        }
-       players[device]->setText(players[device]->text() + string);
+       QColor textColor = QColor(Qt::blue);
+       players[device]->setText(players[device]->text() + "<span style='color:"+colorToString(textColor)+"'>"+string+"</span>");
 }
 
 bool MultypoWindow::handleX11Event(XEvent *event)