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