From d45ad3325c584b3aed9d2768df00e0e1b62d63b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Sat, 18 Feb 2012 00:36:36 +0100 Subject: [PATCH] Simplify the New Game dialog by removing various controls --- qt/fav_players_dialog.cpp | 12 +--- qt/fav_players_dialog.h | 3 - qt/new_game.cpp | 31 +--------- qt/new_game.h | 2 - qt/players_table_helper.cpp | 10 +--- qt/ui/new_game.ui | 112 ++++++------------------------------ 6 files changed, 23 insertions(+), 147 deletions(-) diff --git a/qt/fav_players_dialog.cpp b/qt/fav_players_dialog.cpp index a1a3a80..9b60b59 100644 --- a/qt/fav_players_dialog.cpp +++ b/qt/fav_players_dialog.cpp @@ -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)); diff --git a/qt/fav_players_dialog.h b/qt/fav_players_dialog.h index f586b9c..e094d79 100644 --- a/qt/fav_players_dialog.h +++ b/qt/fav_players_dialog.h @@ -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; diff --git a/qt/new_game.cpp b/qt/new_game.cpp index d55efe7..e91a7d2 100644 --- a/qt/new_game.cpp +++ b/qt/new_game.cpp @@ -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) diff --git a/qt/new_game.h b/qt/new_game.h index 45ef33f..23a4f3c 100644 --- a/qt/new_game.h +++ b/qt/new_game.h @@ -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); diff --git a/qt/players_table_helper.cpp b/qt/players_table_helper.cpp index f51e5ff..fd92d9e 100644 --- a/qt/players_table_helper.cpp +++ b/qt/players_table_helper.cpp @@ -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); } diff --git a/qt/ui/new_game.ui b/qt/ui/new_game.ui index 1e38c89..75e802d 100644 --- a/qt/ui/new_game.ui +++ b/qt/ui/new_game.ui @@ -133,92 +133,9 @@ _("Players") - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - _("Add favorite players...") - - - - - - - - - - - _("Name:") - - - - - - - Player 2 - - - - - - - _("Type:") - - - - - - - - _("Human") - - - - - _("Computer") - - - - - - - - _("Level:") - - - - - - - false - - - 100 - - - 100 - - - - - @@ -228,6 +145,13 @@ + + + + _("Add favorite players...") + + + @@ -241,16 +165,6 @@ - - - - false - - - _("Remove player") - - - @@ -268,6 +182,18 @@ + + radioButtonDuplicate + radioButtonFreeGame + radioButtonTraining + checkBoxJoker + checkBoxExplosive + checkBox7Among8 + pushButtonAdd + buttonAddFav + tablePlayers + buttonBox +