mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
Simplify the New Game dialog by removing various controls
This commit is contained in:
parent
9d987974cd
commit
d45ad3325c
6 changed files with 23 additions and 147 deletions
|
@ -35,23 +35,13 @@ FavPlayersDialog::FavPlayersDialog(QWidget *iParent)
|
|||
{
|
||||
setupUi(this);
|
||||
|
||||
m_helper = new PlayersTableHelper(this, tablePlayers, NULL, buttonRemove);
|
||||
m_helper = new PlayersTableHelper(this, tablePlayers, buttonAdd, buttonRemove);
|
||||
m_helper->addPopupRemoveAction();
|
||||
|
||||
QObject::connect(buttonAdd, SIGNAL(clicked()),
|
||||
this, SLOT(addRow()));
|
||||
|
||||
m_helper->addPlayers(m_helper->getFavPlayers());
|
||||
}
|
||||
|
||||
|
||||
void FavPlayersDialog::addRow()
|
||||
{
|
||||
m_helper->addPlayer(PlayerDef(_q("New player"), _q(PlayersTableHelper::kHUMAN), ""),
|
||||
true, true);
|
||||
}
|
||||
|
||||
|
||||
void FavPlayersDialog::accept()
|
||||
{
|
||||
m_helper->saveFavPlayers(m_helper->getPlayers(false));
|
||||
|
|
|
@ -42,9 +42,6 @@ public slots:
|
|||
/// Update the settings when the user selects "OK"
|
||||
virtual void accept();
|
||||
|
||||
private slots:
|
||||
void addRow();
|
||||
|
||||
private:
|
||||
PlayersTableHelper *m_helper;
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ NewGame::NewGame(QWidget *iParent)
|
|||
: QDialog(iParent)
|
||||
{
|
||||
setupUi(this);
|
||||
lineEditName->setText(_q("Player %1").arg(2));
|
||||
|
||||
checkBoxJoker->setToolTip(_q(
|
||||
"In a joker game, each rack contains a joker.\n"
|
||||
|
@ -63,7 +62,7 @@ NewGame::NewGame(QWidget *iParent)
|
|||
"but at most 7 can be played at the same time.\n"
|
||||
"This allows for more combinations during the game, and thus higher scores."));
|
||||
|
||||
m_helper = new PlayersTableHelper(this, tablePlayers, NULL, pushButtonRemove);
|
||||
m_helper = new PlayersTableHelper(this, tablePlayers, pushButtonAdd);
|
||||
m_helper->addPopupRemoveAction();
|
||||
QAction *addToFavAction = new QAction(_q("Mark the selected player(s) as favorites"), this);
|
||||
addToFavAction->setStatusTip(_q("Add the selected player(s) to the list of favorite players"));
|
||||
|
@ -84,9 +83,6 @@ NewGame::NewGame(QWidget *iParent)
|
|||
m_helper->addPlayer(PlayerDef(_q("Player %1").arg(1), _q(kHUMAN), ""));
|
||||
m_helper->addPlayer(PlayerDef(_q("Eliot"), _q(kAI), QString("%1").arg(defLevel)));
|
||||
|
||||
// Enable the Level spinbox only when the player is a computer
|
||||
QObject::connect(comboBoxType, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(enableLevelSpinBox(int)));
|
||||
// Enable the Ok button only if there are enough players for the
|
||||
// current mode
|
||||
QObject::connect(m_helper, SIGNAL(rowCountChanged()),
|
||||
|
@ -176,12 +172,6 @@ PublicGame * NewGame::createGame(const Dictionary &iDic) const
|
|||
}
|
||||
|
||||
|
||||
void NewGame::enableLevelSpinBox(int index)
|
||||
{
|
||||
spinBoxLevel->setEnabled(index == 1);
|
||||
}
|
||||
|
||||
|
||||
void NewGame::enableOkButton()
|
||||
{
|
||||
// Enable the "Ok" button:
|
||||
|
@ -241,25 +231,6 @@ void NewGame::addFavoritePlayers()
|
|||
}
|
||||
|
||||
|
||||
void NewGame::on_pushButtonAdd_clicked()
|
||||
{
|
||||
// Add a new row
|
||||
PlayerDef def(lineEditName->displayText(),
|
||||
comboBoxType->currentText(),
|
||||
spinBoxLevel->isEnabled() ?
|
||||
QString("%1").arg(spinBoxLevel->value()) : "");
|
||||
m_helper->addPlayer(def, true);
|
||||
|
||||
// Increment the player ID
|
||||
static int currPlayer = 2;
|
||||
if (lineEditName->displayText() == _q("Player %1").arg(currPlayer))
|
||||
{
|
||||
++currPlayer;
|
||||
lineEditName->setText(_q("Player %1").arg(currPlayer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NewGame::on_checkBoxJoker_stateChanged(int newState)
|
||||
{
|
||||
if (newState == Qt::Checked)
|
||||
|
|
|
@ -51,14 +51,12 @@ public:
|
|||
PublicGame * createGame(const Dictionary& iDic) const;
|
||||
|
||||
private slots:
|
||||
void enableLevelSpinBox(int);
|
||||
void enableOkButton();
|
||||
void enablePlayers(bool);
|
||||
void addSelectedToFav();
|
||||
void addFavoritePlayers();
|
||||
|
||||
// The following slots are automatically connected
|
||||
void on_pushButtonAdd_clicked();
|
||||
void on_checkBoxJoker_stateChanged(int);
|
||||
void on_checkBoxExplosive_stateChanged(int);
|
||||
|
||||
|
|
|
@ -174,14 +174,8 @@ void PlayersTableHelper::removeSelectedRows()
|
|||
|
||||
void PlayersTableHelper::addRow()
|
||||
{
|
||||
addRow(PlayerDef(_q("New player"), _q(kHUMAN), ""));
|
||||
// Give focus to the newly created cell containing the player name,
|
||||
// to allow fast edition
|
||||
m_tablePlayers->setFocus();
|
||||
m_tablePlayers->setCurrentCell(m_tablePlayers->rowCount() - 1, 0,
|
||||
QItemSelectionModel::ClearAndSelect |
|
||||
QItemSelectionModel::Current |
|
||||
QItemSelectionModel::Rows);
|
||||
addPlayer(PlayerDef(_q("New player"), _q(kHUMAN), ""),
|
||||
true, true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -133,92 +133,9 @@
|
|||
<string>_("Players")</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonAddFav">
|
||||
<property name="text">
|
||||
<string>_("Add favorite players...")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tablePlayers"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>_("Name:")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditName">
|
||||
<property name="text">
|
||||
<string>Player 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>_("Type:")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>_("Human")</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>_("Computer")</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>_("Level:")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBoxLevel">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
|
@ -228,6 +145,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonAddFav">
|
||||
<property name="text">
|
||||
<string>_("Add favorite players...")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
|
@ -241,16 +165,6 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonRemove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>_("Remove player")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -268,6 +182,18 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>radioButtonDuplicate</tabstop>
|
||||
<tabstop>radioButtonFreeGame</tabstop>
|
||||
<tabstop>radioButtonTraining</tabstop>
|
||||
<tabstop>checkBoxJoker</tabstop>
|
||||
<tabstop>checkBoxExplosive</tabstop>
|
||||
<tabstop>checkBox7Among8</tabstop>
|
||||
<tabstop>pushButtonAdd</tabstop>
|
||||
<tabstop>buttonAddFav</tabstop>
|
||||
<tabstop>tablePlayers</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
Loading…
Reference in a new issue