diff --git a/startgamedialog.cpp b/startgamedialog.cpp index d0478e016e10552c081db716f6f6d2b1adb803fe..c645c0c466e543e8d1bfd127dfb73094a87d8c85 100644 --- a/startgamedialog.cpp +++ b/startgamedialog.cpp @@ -27,6 +27,12 @@ StartGameDialog::StartGameDialog(QWidget *parent) : ui->blackTypeGroup->setId(ui->blackHuman, GameStartInformation::Human); ui->blackTypeGroup->setId(ui->blackAI, GameStartInformation::AI); + + connect(ui->blackTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(slotUpdateBlack(int))); + connect(ui->whiteTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(slotUpdateWhite(int))); + + slotUpdateBlack(GameStartInformation::Human); + slotUpdateWhite(GameStartInformation::AI); } StartGameDialog::~StartGameDialog() @@ -53,3 +59,24 @@ GameStartInformation StartGameDialog::createGameStartInformation() const return info; } + + +void StartGameDialog::slotUpdateBlack(int clickedId) +{ + ui->blackSkill->setEnabled(clickedId == GameStartInformation::AI); + ui->blackName->setEnabled(clickedId == GameStartInformation::Human); + if (clickedId == GameStartInformation::Human) + ui->blackName->setText(m_user.loginName()); + else + ui->blackName->setText("Computer"); +} + +void StartGameDialog::slotUpdateWhite(int clickedId) +{ + ui->whiteSkill->setEnabled(clickedId == GameStartInformation::AI); + ui->whiteName->setEnabled(clickedId == GameStartInformation::Human); + if (clickedId == GameStartInformation::Human) + ui->whiteName->setText(m_user.loginName()); + else + ui->whiteName->setText("Computer"); +} diff --git a/startgamedialog.h b/startgamedialog.h index ec225aae6d08785df861015488053596f88fada9..bba58899501c76d1660875c9cfff41d254a6fd57 100644 --- a/startgamedialog.h +++ b/startgamedialog.h @@ -4,6 +4,7 @@ #include #include "gamestartinformation.h" #include "commondefs.h" +#include namespace Ui { class StartGameDialog; @@ -22,11 +23,15 @@ public: signals: void startGame(); +private slots: + void slotUpdateBlack(int clickedId); + void slotUpdateWhite(int clickedId); + private: + void slotButtonClicked(int button); Ui::StartGameDialog *ui; QWidget *m_contents; - void slotButtonClicked(int button); - + KUser m_user; }; #endif // STARTGAMEDIALOG_H diff --git a/startgamedialog.ui b/startgamedialog.ui index e342c4ac7924f50ecf3f12ddb95dfe46927c3eaf..68ebe8495aafe178f1e14cab431e2f61033269ec 100644 --- a/startgamedialog.ui +++ b/startgamedialog.ui @@ -11,64 +11,20 @@ - - - - QLayout::SetMaximumSize - - - - - Black - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - VS - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - White - - - - - + + + + Black + + + Qt::AlignCenter + + + @@ -163,8 +119,38 @@ + + + + VS + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + White + + + Qt::AlignCenter + + +