Commit 6b44917b authored by Denis Kuplyakov's avatar Denis Kuplyakov

Improved UI of StartGameDialog

Now username automatically installed according to KDE profile, skill
combo is disabled when Human player is selected. Some other minor
additions.
parent 293082b7
...@@ -27,6 +27,12 @@ StartGameDialog::StartGameDialog(QWidget *parent) : ...@@ -27,6 +27,12 @@ StartGameDialog::StartGameDialog(QWidget *parent) :
ui->blackTypeGroup->setId(ui->blackHuman, GameStartInformation::Human); ui->blackTypeGroup->setId(ui->blackHuman, GameStartInformation::Human);
ui->blackTypeGroup->setId(ui->blackAI, GameStartInformation::AI); 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() StartGameDialog::~StartGameDialog()
...@@ -53,3 +59,24 @@ GameStartInformation StartGameDialog::createGameStartInformation() const ...@@ -53,3 +59,24 @@ GameStartInformation StartGameDialog::createGameStartInformation() const
return info; 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");
}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <KDialog> #include <KDialog>
#include "gamestartinformation.h" #include "gamestartinformation.h"
#include "commondefs.h" #include "commondefs.h"
#include <KUser>
namespace Ui { namespace Ui {
class StartGameDialog; class StartGameDialog;
...@@ -22,11 +23,15 @@ public: ...@@ -22,11 +23,15 @@ public:
signals: signals:
void startGame(); void startGame();
private slots:
void slotUpdateBlack(int clickedId);
void slotUpdateWhite(int clickedId);
private: private:
void slotButtonClicked(int button);
Ui::StartGameDialog *ui; Ui::StartGameDialog *ui;
QWidget *m_contents; QWidget *m_contents;
void slotButtonClicked(int button); KUser m_user;
}; };
#endif // STARTGAMEDIALOG_H #endif // STARTGAMEDIALOG_H
...@@ -11,64 +11,20 @@ ...@@ -11,64 +11,20 @@
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Black</string>
</property>
</widget>
</item>
<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="QLabel" name="label_2">
<property name="text">
<string>VS</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<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="QLabel" name="label_3">
<property name="text">
<string>White</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Black</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
...@@ -163,8 +119,38 @@ ...@@ -163,8 +119,38 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>VS</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<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> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>White</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment