there are players now :-) every game is better with players
[multypo.git] / qt / player.cpp
1 #include "player.h"
2
3 #include <QLayout>
4
5 static QString colorToString(QColor col)
6 {
7         return QString("#%1%2%3").arg(col.red(), 2, 16, QChar('0'))
8                         .arg(col.green(), 2, 16, QChar('0'))
9                         .arg(col.blue(), 2, 16, QChar('0'));
10 }
11
12 Player::Player(QWidget* parent) {
13         theLabel = new QLabel (parent);
14         parent->layout()->addWidget(theLabel);
15 }
16
17 void Player::handleKey(QString str) {
18         if (str.length() == 1) {
19                 currentLine += str;
20         } else if (name.isNull() && str == "Return") {
21                 // set name
22                 name = currentLine;
23                 currentLine = "";
24         } else if (str == "BackSpace") {
25                 currentLine.chop(1);
26         }
27         theLabel->setText(currentLine);
28 }