mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-13 20:03:23 +01:00
PlayWordMediator: improve the handling of words in Intermediate state.
The syntactically invalid words (such as those without matching parens) are displayed in red, and do not trigger un update of the PlayModel. As a result, the letters do not disappear from the preview anymore when the opening parenthesis of a blank tile is typed.
This commit is contained in:
parent
d9ee0633db
commit
6f2ee6f9ff
2 changed files with 24 additions and 6 deletions
|
@ -45,6 +45,10 @@ PlayWordMediator::PlayWordMediator(QObject *parent, QLineEdit &iEditPlay,
|
|||
{
|
||||
SetTooltips(m_lineEditPlay, m_lineEditCoord);
|
||||
|
||||
blackPalette = m_lineEditPlay.palette();
|
||||
redPalette = m_lineEditPlay.palette();
|
||||
redPalette.setColor(QPalette::Text, Qt::red);
|
||||
|
||||
/// Set validators;
|
||||
if (m_game)
|
||||
{
|
||||
|
@ -170,6 +174,11 @@ void PlayWordMediator::onCoordChanged()
|
|||
|
||||
void PlayWordMediator::onWordChanged()
|
||||
{
|
||||
bool acceptableInput = m_lineEditPlay.hasAcceptableInput();
|
||||
m_lineEditPlay.setPalette(acceptableInput ? blackPalette : redPalette);
|
||||
|
||||
if (acceptableInput)
|
||||
{
|
||||
wstring playedWord;
|
||||
GetPlayedWord(m_lineEditPlay, m_game->getDic(), &playedWord, NULL);
|
||||
|
||||
|
@ -177,6 +186,7 @@ void PlayWordMediator::onWordChanged()
|
|||
m_game->checkPlayedWord(playedWord, wfq(m_lineEditCoord.text()), move);
|
||||
m_playModel.setMove(move);
|
||||
updatePointsAndState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <QtGui/QValidator>
|
||||
#include <QtGui/QPalette>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
|
@ -102,6 +103,13 @@ private:
|
|||
QPushButton &m_pushButtonPlay;
|
||||
PlayModel &m_playModel;
|
||||
|
||||
/// Palette to write text in black
|
||||
QPalette blackPalette;
|
||||
|
||||
/// Palette to write text in red
|
||||
QPalette redPalette;
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper around GetPlayedWord(), more practical to use.
|
||||
* But it should be called only for a valid input!
|
||||
|
|
Loading…
Reference in a new issue