From bbb0ee4510f7ddb2c4475f67563012de378e3f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Sat, 15 Jan 2011 16:33:02 +0000 Subject: [PATCH] In free game mode, the "Change" button cannot be used anymore to pass without changing any letter. This should be more intuitive. --- qt/player_widget.cpp | 20 +++++++++++++++++--- qt/player_widget.h | 4 +++- qt/ui/player_widget.ui | 3 +++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/qt/player_widget.cpp b/qt/player_widget.cpp index d7b94a9..c35b026 100644 --- a/qt/player_widget.cpp +++ b/qt/player_widget.cpp @@ -140,19 +140,33 @@ void PlayerWidget::on_lineEditChange_textChanged() { pushButtonChange->setEnabled(lineEditChange->hasAcceptableInput() && lineEditChange->text() != ""); - pushButtonPass->setEnabled(lineEditChange->text() == ""); } void PlayerWidget::on_lineEditChange_returnPressed() { ASSERT(m_game->getMode() == PublicGame::kFREEGAME, - "Trying to pass or change letters while not in free game mode"); + "Trying to change letters while not in free game mode"); - QString inputLetters = lineEditChange->text(); + pass(lineEditChange->text()); +} + + +void PlayerWidget::on_pushButtonPass_clicked() +{ + ASSERT(m_game->getMode() == PublicGame::kFREEGAME, + "Trying to pass while not in free game mode"); + + pass(""); +} + + +void PlayerWidget::pass(QString inputLetters) +{ // Convert the input string into an internal one const wstring &letters = m_game->getDic().convertFromInput(qtw(inputLetters)); + // Pass the turn (and possibly change letters) int res = m_game->freeGamePass(letters); if (res == 0) diff --git a/qt/player_widget.h b/qt/player_widget.h index 07bb490..25ec60e 100644 --- a/qt/player_widget.h +++ b/qt/player_widget.h @@ -56,11 +56,13 @@ protected: private slots: void on_pushButtonShuffle_clicked(); void on_pushButtonChange_clicked() { on_lineEditChange_returnPressed(); } - void on_pushButtonPass_clicked() { on_lineEditChange_returnPressed(); } + void on_pushButtonPass_clicked(); void on_lineEditChange_textChanged(); void on_lineEditChange_returnPressed(); private: + void pass(QString inputLetters); + /// Encapsulated game, can be NULL PublicGame *m_game; diff --git a/qt/ui/player_widget.ui b/qt/ui/player_widget.ui index bbd89d7..ecf1297 100644 --- a/qt/ui/player_widget.ui +++ b/qt/ui/player_widget.ui @@ -48,6 +48,9 @@ + + false + _("Change")