mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
Arbitration: when a player is selected, automatically switch to the corresponding history tab
This commit is contained in:
parent
1ad1ef7425
commit
f7a7eab3a3
6 changed files with 42 additions and 5 deletions
|
@ -97,6 +97,11 @@ ArbitAssignments::ArbitAssignments(QWidget *parent, PublicGame *iGame)
|
|||
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT(enableAssignmentButtons()));
|
||||
|
||||
// Emit the "playerSelected" signal when appropriate
|
||||
QObject::connect(treeViewPlayers->selectionModel(),
|
||||
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT(emitPlayerSelected()));
|
||||
|
||||
// Move assignment
|
||||
QObject::connect(buttonSelectMaster, SIGNAL(clicked()),
|
||||
this, SLOT(assignMasterMove()));
|
||||
|
@ -304,6 +309,14 @@ bool ArbitAssignments::hasSelectedPlayer() const
|
|||
}
|
||||
|
||||
|
||||
void ArbitAssignments::emitPlayerSelected()
|
||||
{
|
||||
QSet<unsigned int> playersIdSet = getSelectedPlayers();
|
||||
if (playersIdSet.size() == 1)
|
||||
emit playerSelected(*playersIdSet.begin());
|
||||
}
|
||||
|
||||
|
||||
QSet<unsigned int> ArbitAssignments::getSelectedPlayers() const
|
||||
{
|
||||
QSet<unsigned int> playersIdSet;
|
||||
|
|
|
@ -60,6 +60,7 @@ signals:
|
|||
void notifyProblem(QString iMsg);
|
||||
void notifyInfo(QString iMsg);
|
||||
void endOfTurn();
|
||||
void playerSelected(unsigned playerId);
|
||||
|
||||
public slots:
|
||||
void refresh();
|
||||
|
@ -72,6 +73,7 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void on_checkBoxHideAssigned_toggled(bool);
|
||||
void emitPlayerSelected();
|
||||
void showMasterPreview();
|
||||
void populatePlayersMenu(QMenu &iMenu, const QPoint &iPoint);
|
||||
void assignTopMove();
|
||||
|
|
|
@ -69,6 +69,8 @@ ArbitrationWidget::ArbitrationWidget(QWidget *parent,
|
|||
this, SIGNAL(notifyInfo(QString)));
|
||||
QObject::connect(m_assignmentsWidget, SIGNAL(endOfTurn()),
|
||||
this, SLOT(endOfTurnRefresh()));
|
||||
QObject::connect(m_assignmentsWidget, SIGNAL(playerSelected(unsigned)),
|
||||
this, SIGNAL(playerSelected(unsigned)));
|
||||
|
||||
m_keyAccum = new KeyAccumulator(this, 400);
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ signals:
|
|||
void notifyInfo(QString iMsg);
|
||||
void rackUpdated(const QString &iRack);
|
||||
void requestDefinition(QString iWord);
|
||||
void playerSelected(unsigned playerId);
|
||||
|
||||
public slots:
|
||||
void refresh();
|
||||
|
|
|
@ -157,15 +157,15 @@ MainWindow::MainWindow(QWidget *iParent)
|
|||
|
||||
#if 1
|
||||
// History
|
||||
HistoryTabWidget *historyTab = new HistoryTabWidget;
|
||||
m_historyTabWidget = new HistoryTabWidget;
|
||||
QObject::connect(this, SIGNAL(gameChanged(const PublicGame*)),
|
||||
historyTab, SLOT(setGame(const PublicGame*)));
|
||||
m_historyTabWidget, SLOT(setGame(const PublicGame*)));
|
||||
QObject::connect(this, SIGNAL(gameUpdated()),
|
||||
historyTab, SLOT(refresh()));
|
||||
QObject::connect(historyTab, SIGNAL(requestDefinition(QString)),
|
||||
m_historyTabWidget, SLOT(refresh()));
|
||||
QObject::connect(m_historyTabWidget, SIGNAL(requestDefinition(QString)),
|
||||
this, SLOT(showDefinition(QString)));
|
||||
QHBoxLayout *hlayout2 = new QHBoxLayout;
|
||||
hlayout2->addWidget(historyTab);
|
||||
hlayout2->addWidget(m_historyTabWidget);
|
||||
m_ui.groupBoxHistory->setLayout(hlayout2);
|
||||
#else
|
||||
m_ui.groupBoxHistory->hide();
|
||||
|
@ -412,6 +412,10 @@ void MainWindow::updateForGame(PublicGame *iGame)
|
|||
m_arbitrationWidget, SLOT(refresh()));
|
||||
// Connect with the dictionary tools only if needed
|
||||
linkArbitrationAnd7P1();
|
||||
|
||||
// When a player is selected, show his history
|
||||
QObject::connect(m_arbitrationWidget, SIGNAL(playerSelected(unsigned)),
|
||||
this, SLOT(onPlayerSelected(unsigned)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -497,6 +501,14 @@ void MainWindow::showDefinition(QString iWord)
|
|||
}
|
||||
|
||||
|
||||
void MainWindow::onPlayerSelected(unsigned iPlayerId)
|
||||
{
|
||||
// Select the corresponding tab in the history widget
|
||||
// Note: we don't do the same for the external history widget...
|
||||
m_historyTabWidget->setCurrentIndex(1 + iPlayerId);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (m_game)
|
||||
|
|
|
@ -37,6 +37,7 @@ class Bag;
|
|||
class Board;
|
||||
class History;
|
||||
class PublicGame;
|
||||
class HistoryTabWidget;
|
||||
class PlayerTabWidget;
|
||||
class ScoreWidget;
|
||||
class TrainingWidget;
|
||||
|
@ -109,6 +110,9 @@ private slots:
|
|||
/** Perform work when the preferences were updated */
|
||||
void prefsUpdated();
|
||||
|
||||
/** Select the correct tab in the history widget when the player changes */
|
||||
void onPlayerSelected(unsigned iPlayerId);
|
||||
|
||||
/**
|
||||
* Perform several updates when the game changes (title bar, status bar,
|
||||
* grey out some menu items, ...)
|
||||
|
@ -131,6 +135,9 @@ private:
|
|||
/// The UI file generated with Qt Designer
|
||||
Ui::MainWindow m_ui;
|
||||
|
||||
/// Widget for the game history
|
||||
HistoryTabWidget *m_historyTabWidget;
|
||||
|
||||
/// Widget for the players
|
||||
PlayerTabWidget *m_playersWidget;
|
||||
|
||||
|
|
Loading…
Reference in a new issue