Arbitration: after the end of turn, give the focus to the rack and select all the letters

This commit is contained in:
Olivier Teulière 2012-04-05 22:46:03 +02:00
parent 537d00714b
commit 7e37cde0c0
4 changed files with 28 additions and 1 deletions

View file

@ -630,6 +630,6 @@ void ArbitAssignments::endTurn()
// FIXME: shouldn't be done here
setEnabled(!m_game->isFinished());
emit gameUpdated();
emit endOfTurn();
}

View file

@ -59,6 +59,7 @@ signals:
void gameUpdated();
void notifyProblem(QString iMsg);
void notifyInfo(QString iMsg);
void endOfTurn();
public slots:
void refresh();

View file

@ -66,6 +66,8 @@ ArbitrationWidget::ArbitrationWidget(QWidget *parent,
this, SIGNAL(notifyProblem(QString)));
QObject::connect(m_assignmentsWidget, SIGNAL(notifyInfo(QString)),
this, SIGNAL(notifyInfo(QString)));
QObject::connect(m_assignmentsWidget, SIGNAL(endOfTurn()),
this, SLOT(endOfTurnRefresh()));
m_keyAccum = new KeyAccumulator(this, 400);
@ -204,6 +206,11 @@ ArbitrationWidget::ArbitrationWidget(QWidget *parent,
this, SIGNAL(requestDefinition(QString)));
refresh();
// Give focus to the rack
// FIXME: for some reason, the focus gets lost later...
lineEditRack->setFocus();
lineEditRack->selectAll();
}
@ -213,9 +220,16 @@ void ArbitrationWidget::refresh()
// Update the rack only if needed, to avoid losing cursor position
QString qrack = qfw(pldRack.toString(PlayedRack::RACK_SIMPLE));
if (qrack != lineEditRack->text()) {
// Save the selection status
bool isAllselected = lineEditRack->text() == lineEditRack->selectedText();
// Must be done before updateResultsModel(), because it will
// indirectly call the clearResults() slot
lineEditRack->setText(qrack);
// Restore the selection
if (isAllselected)
lineEditRack->selectAll();
}
updateResultsModel();
@ -592,6 +606,17 @@ void ArbitrationWidget::selectTableNumber(int key)
}
void ArbitrationWidget::endOfTurnRefresh()
{
// Refresh everything
emit gameUpdated();
// Give focus to the rack
lineEditRack->setFocus();
lineEditRack->selectAll();
}
void ArbitrationWidget::updateSelectedMove()
{
bool hasSelection = treeViewResults->selectionModel()->hasSelection();

View file

@ -72,6 +72,7 @@ private slots:
void updateCoordModel(const QString&);
void populateResultsMenu(QMenu &iMenu, const QPoint &iPoint);
void selectTableNumber(int key);
void endOfTurnRefresh();
private:
/// Encapsulated game, can be NULL