Do not refresh the coordinates for a non-visible player.

This fixes a focus bug, and makes it easier to enter moves for several
human players.
This commit is contained in:
Olivier Teulière 2012-01-17 10:48:36 +01:00
parent c81df46b5e
commit 7fd8a245f8

View file

@ -235,10 +235,21 @@ void PlayWordMediator::lineEditCoord_textChanged(const QString &iText)
void PlayWordMediator::updateCoord(const Coord &, const Coord &iNewCoord) void PlayWordMediator::updateCoord(const Coord &, const Coord &iNewCoord)
{ {
// Ignore updates to non-visible controls (which happens when there
// are several human players).
// It fixes a focus problem.
if (!m_lineEditPlay.isVisible())
return;
if (iNewCoord.isValid() && m_lineEditCoord.text() != qfw(iNewCoord.toString())) if (iNewCoord.isValid() && m_lineEditCoord.text() != qfw(iNewCoord.toString()))
m_lineEditCoord.setText(qfw(iNewCoord.toString())); m_lineEditCoord.setText(qfw(iNewCoord.toString()));
else if (!iNewCoord.isValid() && m_lineEditCoord.hasAcceptableInput()) else if (!iNewCoord.isValid() && m_lineEditCoord.hasAcceptableInput())
m_lineEditCoord.setText(""); m_lineEditCoord.setText("");
// Set the focus to the "Play word" zone is the focus is not
// already on a QLineEdit (because of a click on the board)
if (!m_lineEditPlay.hasFocus() && !m_lineEditCoord.hasFocus())
m_lineEditPlay.setFocus();
lineEditPlay_textChanged(); lineEditPlay_textChanged();
} }