In free game mode, the "Change" button cannot be used anymore to pass without changing any letter.

This should be more intuitive.
This commit is contained in:
Olivier Teulière 2011-01-15 16:33:02 +00:00
parent 6f4c575eb6
commit bbb0ee4510
3 changed files with 23 additions and 4 deletions

View file

@ -140,19 +140,33 @@ void PlayerWidget::on_lineEditChange_textChanged()
{ {
pushButtonChange->setEnabled(lineEditChange->hasAcceptableInput() && pushButtonChange->setEnabled(lineEditChange->hasAcceptableInput() &&
lineEditChange->text() != ""); lineEditChange->text() != "");
pushButtonPass->setEnabled(lineEditChange->text() == "");
} }
void PlayerWidget::on_lineEditChange_returnPressed() void PlayerWidget::on_lineEditChange_returnPressed()
{ {
ASSERT(m_game->getMode() == PublicGame::kFREEGAME, 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 // Convert the input string into an internal one
const wstring &letters = const wstring &letters =
m_game->getDic().convertFromInput(qtw(inputLetters)); m_game->getDic().convertFromInput(qtw(inputLetters));
// Pass the turn (and possibly change letters) // Pass the turn (and possibly change letters)
int res = m_game->freeGamePass(letters); int res = m_game->freeGamePass(letters);
if (res == 0) if (res == 0)

View file

@ -56,11 +56,13 @@ protected:
private slots: private slots:
void on_pushButtonShuffle_clicked(); void on_pushButtonShuffle_clicked();
void on_pushButtonChange_clicked() { on_lineEditChange_returnPressed(); } 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_textChanged();
void on_lineEditChange_returnPressed(); void on_lineEditChange_returnPressed();
private: private:
void pass(QString inputLetters);
/// Encapsulated game, can be NULL /// Encapsulated game, can be NULL
PublicGame *m_game; PublicGame *m_game;

View file

@ -48,6 +48,9 @@
</item> </item>
<item row="2" column="2" colspan="2"> <item row="2" column="2" colspan="2">
<widget class="QPushButton" name="pushButtonChange"> <widget class="QPushButton" name="pushButtonChange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>_(&quot;Change&quot;)</string> <string>_(&quot;Change&quot;)</string>
</property> </property>