X-Git-Url: https://git.ralfj.de/multypo.git/blobdiff_plain/036922ba5e90ae7f6f6abe3f99b1783dec5132fc..e52cebeda021cf4e76330eabd3777ec6136720d3:/qt/player.cpp diff --git a/qt/player.cpp b/qt/player.cpp index 4049788..937bbab 100644 --- a/qt/player.cpp +++ b/qt/player.cpp @@ -1,6 +1,7 @@ #include "player.h" #include +#include static QString colorToString(QColor col) { @@ -12,12 +13,41 @@ static QString colorToString(QColor col) Player::Player(QWidget* parent) { theLabel = new QLabel (parent); parent->layout()->addWidget(theLabel); + modifyable = true; + qDebug() << "Player created"; } -void Player::handleKey(QString str) { +bool Player::hasName() { + return !name.isEmpty(); +} + +QString Player::getName() { + return name; +} + +QString Player::getCurrentLine() { + return currentLine; +} + +void Player::setWaiting(QString labeltext) { + theLabel->setText(labeltext); + modifyable = false; +} + +void Player::resetText() { + currentLine.clear(); + theLabel->setText(currentLine); + modifyable = true; +} + +bool Player::handleKey(QString str) { + if (!modifyable) + return false; + bool newChar = false; if (str.length() == 1) { currentLine += str; - } else if (name.isNull() && str == "Return") { + newChar = true; + } else if (!hasName() && str == "Return") { // set name name = currentLine; currentLine = ""; @@ -25,4 +55,5 @@ void Player::handleKey(QString str) { currentLine.chop(1); } theLabel->setText(currentLine); + return newChar; }