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) :
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");
}
......@@ -4,6 +4,7 @@
#include <KDialog>
#include "gamestartinformation.h"
#include "commondefs.h"
#include <KUser>
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
......@@ -12,63 +12,19 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<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 name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
......@@ -163,8 +119,38 @@
</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>
<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>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<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