mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-17 07:48:27 +01:00
PlayerWidget: improve focus behaviour and ergonomy
This commit is contained in:
parent
18aa839f11
commit
97f4355502
4 changed files with 31 additions and 9 deletions
|
@ -43,7 +43,6 @@ PlayWordMediator::PlayWordMediator(QObject *parent, QLineEdit &iEditPlay,
|
|||
m_lineEditCoord(iEditCoord), m_lineEditPoints(iEditPoints),
|
||||
m_pushButtonPlay(iButtonPlay), m_coordModel(iCoordModel)
|
||||
{
|
||||
m_lineEditPlay.setFocus();
|
||||
SetTooltips(m_lineEditPlay, m_lineEditCoord);
|
||||
|
||||
/// Set validators;
|
||||
|
@ -69,6 +68,13 @@ PlayWordMediator::PlayWordMediator(QObject *parent, QLineEdit &iEditPlay,
|
|||
}
|
||||
|
||||
|
||||
void PlayWordMediator::setCleverFocus()
|
||||
{
|
||||
if (!m_lineEditPlay.hasFocus() && !m_lineEditCoord.hasFocus())
|
||||
m_lineEditPlay.setFocus();
|
||||
}
|
||||
|
||||
|
||||
void PlayWordMediator::SetTooltips(QLineEdit &iEditWord, QLineEdit &iEditCoord)
|
||||
{
|
||||
// These strings cannot be in the .ui file, because of the newlines
|
||||
|
@ -150,7 +156,6 @@ void PlayWordMediator::playWord()
|
|||
if (res == 0)
|
||||
{
|
||||
emit gameUpdated();
|
||||
m_lineEditPlay.setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -229,8 +234,7 @@ void PlayWordMediator::updateCoord(const Coord &, const Coord &iNewCoord)
|
|||
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();
|
||||
setCleverFocus();
|
||||
|
||||
updatePointsAndState();
|
||||
}
|
||||
|
|
|
@ -60,6 +60,12 @@ public:
|
|||
QPushButton &iButtonPlay,
|
||||
CoordModel &iCoordModel, PublicGame *iGame);
|
||||
|
||||
/**
|
||||
* Set the focus on the editWord QLineEdit, unless the focus
|
||||
* is already on the editCoord one.
|
||||
*/
|
||||
void setCleverFocus();
|
||||
|
||||
/**
|
||||
* Set tooltips on the given widgets, to help
|
||||
* the user know how to enter a word.
|
||||
|
|
|
@ -87,6 +87,10 @@ PlayerWidget::PlayerWidget(QWidget *parent, CoordModel &iCoordModel,
|
|||
lineEditChange->setValidator(val);
|
||||
}
|
||||
|
||||
// When the widget gains the focus, transfer it
|
||||
// to the "main" line edit by default
|
||||
setFocusProxy(lineEditPlay);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -130,6 +134,7 @@ void PlayerWidget::shuffle()
|
|||
{
|
||||
m_game->shuffleRack();
|
||||
emit gameUpdated();
|
||||
m_mediator->setCleverFocus();
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,7 +174,10 @@ void PlayerWidget::helperChangePass(QString inputLetters)
|
|||
// Pass the turn (and possibly change letters)
|
||||
int res = m_game->freeGamePass(letters);
|
||||
if (res == 0)
|
||||
{
|
||||
emit gameUpdated();
|
||||
m_mediator->setCleverFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString msg;
|
||||
|
@ -245,6 +253,10 @@ void PlayerTabWidget::refresh()
|
|||
if (m_game)
|
||||
setCurrentIndex(m_game->getCurrentPlayer().getId());
|
||||
emit refreshSignal();
|
||||
|
||||
// Give the focus to the current widget. Without this, the widget does
|
||||
// not get focus in some cases
|
||||
currentWidget()->setFocus();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>533</width>
|
||||
<height>111</height>
|
||||
<width>574</width>
|
||||
<height>113</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
|
@ -28,7 +28,7 @@
|
|||
<item row="0" column="7">
|
||||
<widget class="QPushButton" name="pushButtonShuffle">
|
||||
<property name="text">
|
||||
<string>_("Shuffle")</string>
|
||||
<string>_("Shu&ffle")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -42,7 +42,7 @@
|
|||
<item row="2" column="7">
|
||||
<widget class="QPushButton" name="pushButtonPass">
|
||||
<property name="text">
|
||||
<string>_("Pass")</string>
|
||||
<string>_("&Pass")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -140,7 +140,7 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>_("Change")</string>
|
||||
<string>_("&Change")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue