projects
/
multypo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
allow passing words file as argument
[multypo.git]
/
qt
/
player.cpp
diff --git
a/qt/player.cpp
b/qt/player.cpp
index 871ecb9d474182fd1ad50ddd6790fff4a4d71d42..69e7651432a114a5b6309c11d399e525cfbc715f 100644
(file)
--- a/
qt/player.cpp
+++ b/
qt/player.cpp
@@
-1,6
+1,7
@@
#include "player.h"
#include <QLayout>
#include "player.h"
#include <QLayout>
+#include <QDebug>
static QString colorToString(QColor col)
{
static QString colorToString(QColor col)
{
@@
-9,14
+10,15
@@
static QString colorToString(QColor col)
.arg(col.blue(), 2, 16, QChar('0'));
}
.arg(col.blue(), 2, 16, QChar('0'));
}
-Player::Player(QWidget* parent) {
+Player::Player(QWidget* parent)
: score(0)
{
theLabel = new QLabel (parent);
parent->layout()->addWidget(theLabel);
theLabel = new QLabel (parent);
parent->layout()->addWidget(theLabel);
+ modifyable = true;
+ qDebug() << "Player created";
}
}
-
bool Player::hasName() {
bool Player::hasName() {
- return !name.is
Null
();
+ return !name.is
Empty
();
}
QString Player::getName() {
}
QString Player::getName() {
@@
-27,14
+29,24
@@
QString Player::getCurrentLine() {
return currentLine;
}
return currentLine;
}
+void Player::setWaiting(QString labeltext) {
+ theLabel->setText(labeltext);
+ modifyable = false;
+}
+
void Player::resetText() {
currentLine.clear();
theLabel->setText(currentLine);
void Player::resetText() {
currentLine.clear();
theLabel->setText(currentLine);
+ modifyable = true;
}
}
-void Player::handleKey(QString str) {
+bool Player::handleKey(QString str) {
+ if (!modifyable)
+ return false;
+ bool newChar = false;
if (str.length() == 1) {
currentLine += str;
if (str.length() == 1) {
currentLine += str;
+ newChar = true;
} else if (!hasName() && str == "Return") {
// set name
name = currentLine;
} else if (!hasName() && str == "Return") {
// set name
name = currentLine;
@@
-43,4
+55,5
@@
void Player::handleKey(QString str) {
currentLine.chop(1);
}
theLabel->setText(currentLine);
currentLine.chop(1);
}
theLabel->setText(currentLine);
+ return newChar;
}
}