qnetdice

changeset 1:92377189a5c6

moving along
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 22 Dec 2013 04:08:50 +0200
parents 0e9c16d77e47
children ad12da657c00
files data/dice/d10.png data/dice/d100.png data/dice/d12.png data/dice/d20.png data/dice/d4.png data/dice/d6.png data/dice/d8.png data/icons/edit-add-2.png data/icons/edit-clear-2.png qnetdice.pro qnetdice.qrc src/logger.cc src/logger.h src/main.cc src/main.h src/mainwin.cc src/mainwin.h src/roll.cc src/roll.h src/rollwidget.cc src/rollwidget.h ui/mainwin.ui ui/server.ui
diffstat 23 files changed, 640 insertions(+), 34 deletions(-) [+]
line diff
     1.1 Binary file data/dice/d10.png has changed
     2.1 Binary file data/dice/d100.png has changed
     3.1 Binary file data/dice/d12.png has changed
     4.1 Binary file data/dice/d20.png has changed
     5.1 Binary file data/dice/d4.png has changed
     6.1 Binary file data/dice/d6.png has changed
     7.1 Binary file data/dice/d8.png has changed
     8.1 Binary file data/icons/edit-add-2.png has changed
     9.1 Binary file data/icons/edit-clear-2.png has changed
    10.1 --- a/qnetdice.pro	Thu Dec 19 13:34:40 2013 +0200
    10.2 +++ b/qnetdice.pro	Sun Dec 22 04:08:50 2013 +0200
    10.3 @@ -4,7 +4,7 @@
    10.4  #
    10.5  #-------------------------------------------------
    10.6  
    10.7 -QT       += core gui
    10.8 +QT       += core gui network
    10.9  
   10.10  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
   10.11  
   10.12 @@ -15,10 +15,18 @@
   10.13  SOURCES +=\
   10.14  	src/mainwin.cc \
   10.15      src/main.cc \
   10.16 -    src/dicedialog.cc
   10.17 +    src/rollwidget.cc \
   10.18 +    src/roll.cc \
   10.19 +    src/logger.cc
   10.20  
   10.21  HEADERS  += src/mainwin.h \
   10.22 -    src/dicedialog.h
   10.23 +    src/rollwidget.h \
   10.24 +    src/roll.h \
   10.25 +    src/main.h \
   10.26 +    src/logger.h
   10.27  
   10.28  FORMS    += ui/mainwin.ui \
   10.29 -    ui/dicedialog.ui
   10.30 +    ui/server.ui
   10.31 +
   10.32 +RESOURCES += \
   10.33 +    qnetdice.qrc
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/qnetdice.qrc	Sun Dec 22 04:08:50 2013 +0200
    11.3 @@ -0,0 +1,13 @@
    11.4 +<RCC>
    11.5 +    <qresource prefix="/">
    11.6 +        <file>data/dice/d4.png</file>
    11.7 +        <file>data/dice/d6.png</file>
    11.8 +        <file>data/dice/d8.png</file>
    11.9 +        <file>data/dice/d10.png</file>
   11.10 +        <file>data/dice/d12.png</file>
   11.11 +        <file>data/dice/d20.png</file>
   11.12 +        <file>data/dice/d100.png</file>
   11.13 +        <file>data/icons/edit-add-2.png</file>
   11.14 +        <file>data/icons/edit-clear-2.png</file>
   11.15 +    </qresource>
   11.16 +</RCC>
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/logger.cc	Sun Dec 22 04:08:50 2013 +0200
    12.3 @@ -0,0 +1,74 @@
    12.4 +#include <stdio.h>
    12.5 +#include <stdlib.h>
    12.6 +#include <string.h>
    12.7 +#include <stdarg.h>
    12.8 +#include <list>
    12.9 +#include "logger.h"
   12.10 +
   12.11 +struct LogTarget {
   12.12 +	enum LogTargetType { LOG_TYPE_STREAM, LOG_TYPE_CALLBACK } type;
   12.13 +	FILE *fp;
   12.14 +	void (*func)(const char*, void*);
   12.15 +	void *func_cls;
   12.16 +};
   12.17 +
   12.18 +static void logmsg(LogTarget &out, const char *msg);
   12.19 +
   12.20 +static LogTarget def_log_target = {	LogTarget::LOG_TYPE_STREAM, stderr, 0, 0 };
   12.21 +static std::list<LogTarget> targets;
   12.22 +
   12.23 +void set_log_file(FILE *fp)
   12.24 +{
   12.25 +	LogTarget targ;
   12.26 +	memset(&targ, 0, sizeof targ);
   12.27 +	targ.type = LogTarget::LOG_TYPE_STREAM;
   12.28 +	targ.fp = fp;
   12.29 +	targets.push_back(targ);
   12.30 +}
   12.31 +
   12.32 +void set_log_callback(void (*cb)(const char*, void*), void *cls)
   12.33 +{
   12.34 +	LogTarget targ;
   12.35 +	memset(&targ, 0, sizeof targ);
   12.36 +	targ.type = LogTarget::LOG_TYPE_CALLBACK;
   12.37 +	targ.func = cb;
   12.38 +	targ.func_cls = cls;
   12.39 +	targets.push_back(targ);
   12.40 +}
   12.41 +
   12.42 +void log_message(const char *fmt, ...)
   12.43 +{
   12.44 +	static char buf[512];
   12.45 +
   12.46 +	va_list ap;
   12.47 +	va_start(ap, fmt);
   12.48 +	vsnprintf(buf, sizeof buf, fmt, ap);
   12.49 +	va_end(ap);
   12.50 +
   12.51 +	if(targets.empty()) {
   12.52 +		logmsg(def_log_target, buf);
   12.53 +	} else {
   12.54 +		std::list<LogTarget>::iterator it = targets.begin();
   12.55 +		while(it != targets.end()) {
   12.56 +			logmsg(*it++, buf);
   12.57 +		}
   12.58 +	}
   12.59 +}
   12.60 +
   12.61 +
   12.62 +static void logmsg(LogTarget &out, const char *msg)
   12.63 +{
   12.64 +	switch(out.type) {
   12.65 +	case LogTarget::LOG_TYPE_STREAM:
   12.66 +		fputs(msg, out.fp);
   12.67 +		fflush(out.fp);
   12.68 +		break;
   12.69 +
   12.70 +	case LogTarget::LOG_TYPE_CALLBACK:
   12.71 +		out.func(msg, out.func_cls);
   12.72 +		break;
   12.73 +
   12.74 +	default:
   12.75 +		break;
   12.76 +	}
   12.77 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/logger.h	Sun Dec 22 04:08:50 2013 +0200
    13.3 @@ -0,0 +1,9 @@
    13.4 +#ifndef LOGGER_H_
    13.5 +#define LOGGER_H_
    13.6 +
    13.7 +void set_log_file(FILE *fp);
    13.8 +void set_log_callback(void (*cb)(const char*, void*), void *cls);
    13.9 +
   13.10 +void log_message(const char *msg, ...);
   13.11 +
   13.12 +#endif	// LOGGER_H_
    14.1 --- a/src/main.cc	Thu Dec 19 13:34:40 2013 +0200
    14.2 +++ b/src/main.cc	Sun Dec 22 04:08:50 2013 +0200
    14.3 @@ -1,11 +1,72 @@
    14.4 +#include <stdlib.h>
    14.5 +#include <time.h>
    14.6 +#include <vector>
    14.7 +#include <QApplication>
    14.8 +#include <QStatusBar>
    14.9 +#include "main.h"
   14.10  #include "mainwin.h"
   14.11 -#include <QApplication>
   14.12 +#include "roll.h"
   14.13 +#include "logger.h"
   14.14 +
   14.15 +static void new_client();
   14.16 +static void status_log(const char *msg, void *cls);
   14.17 +
   14.18 +std::vector<Roll*> dice;
   14.19 +QTcpServer *server;
   14.20 +std::vector<QTcpSocket*> clients;
   14.21 +
   14.22 +QTcpSocket *socket;
   14.23 +
   14.24 +static std::string srv_passwd;
   14.25 +static MainWindow win_main;
   14.26  
   14.27  int main(int argc, char *argv[])
   14.28  {
   14.29 -    QApplication a(argc, argv);
   14.30 -    MainWindow w;
   14.31 -    w.show();
   14.32 +	srand(time(0));
   14.33  
   14.34 -    return a.exec();
   14.35 +	QApplication app(argc, argv);
   14.36 +	win_main.show();
   14.37 +
   14.38 +	set_log_file(stdout);
   14.39 +	set_log_callback(status_log, win_main.statusBar());
   14.40 +
   14.41 +	return app.exec();
   14.42  }
   14.43 +
   14.44 +
   14.45 +void start_server(int port, const char *passwd)
   14.46 +{
   14.47 +	if(server) return;
   14.48 +
   14.49 +	log_message("starting server on port: %d\n", port);
   14.50 +
   14.51 +	server = new QTcpServer;
   14.52 +	server->listen(QHostAddress::Any, port);
   14.53 +	srv_passwd = passwd;
   14.54 +
   14.55 +	QObject::connect(server, &QTcpServer::newConnection, new_client);
   14.56 +}
   14.57 +
   14.58 +
   14.59 +static void new_client()
   14.60 +{
   14.61 +	QTcpSocket *sock = server->nextPendingConnection();
   14.62 +	if(!sock) return;
   14.63 +
   14.64 +	QHostAddress client_addr = sock->peerAddress();
   14.65 +	clients.push_back(sock);
   14.66 +
   14.67 +	log_message("received connection request from: %s\n", client_addr.toString().toUtf8().data());
   14.68 +}
   14.69 +
   14.70 +void connect(const char *host, int port, const char *passwd)
   14.71 +{
   14.72 +	log_message("connecting to host: %s port: %d\n", host, port);
   14.73 +}
   14.74 +
   14.75 +
   14.76 +static void status_log(const char *msg, void *cls)
   14.77 +{
   14.78 +	QStatusBar *sbar = (QStatusBar*)cls;
   14.79 +	sbar->showMessage(msg);
   14.80 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/main.h	Sun Dec 22 04:08:50 2013 +0200
    15.3 @@ -0,0 +1,17 @@
    15.4 +#ifndef MAIN_H_
    15.5 +#define MAIN_H_
    15.6 +
    15.7 +#include <vector>
    15.8 +#include <QtNetwork/QTcpServer>
    15.9 +#include <QtNetwork/QTcpSocket>
   15.10 +#include "roll.h"
   15.11 +
   15.12 +extern std::vector<Roll*> dice;
   15.13 +
   15.14 +extern QTcpServer *server;
   15.15 +extern QTcpSocket *sock;
   15.16 +
   15.17 +void start_server(int port, const char *passwd);
   15.18 +void start_client(const char *host, int port, const char *passwd);
   15.19 +
   15.20 +#endif	// MAIN_H_
    16.1 --- a/src/mainwin.cc	Thu Dec 19 13:34:40 2013 +0200
    16.2 +++ b/src/mainwin.cc	Sun Dec 22 04:08:50 2013 +0200
    16.3 @@ -1,14 +1,73 @@
    16.4  #include "mainwin.h"
    16.5  #include "ui_mainwin.h"
    16.6 +#include "ui_server.h"
    16.7 +#include "rollwidget.h"
    16.8 +#include "main.h"
    16.9  
   16.10 -MainWindow::MainWindow(QWidget *parent) :
   16.11 -    QMainWindow(parent),
   16.12 -    ui(new Ui::MainWindow)
   16.13 +MainWindow::MainWindow(QWidget *parent)
   16.14 +	: QMainWindow(parent),
   16.15 +	ui(new Ui::MainWindow)
   16.16  {
   16.17 -    ui->setupUi(this);
   16.18 +	ui->setupUi(this);
   16.19 +
   16.20 +	dicebox = new QVBoxLayout;
   16.21 +	ui->sarea_main_cont->setLayout(dicebox);
   16.22 +
   16.23 +	connect(ui->bn_add, SIGNAL(clicked()), this, SLOT(add_dice()));
   16.24 +	connect(ui->bn_clear, SIGNAL(clicked()), this, SLOT(clear_dice()));
   16.25 +	connect(ui->bn_roll_all, SIGNAL(clicked()), this, SLOT(roll_all()));
   16.26 +
   16.27 +	//connect(ui->action_connect, SIGNAL(triggered()), this, SLOT(start_client()));
   16.28 +	//connect(ui->action_start_server, SIGNAL(triggered()), this, SLOT(start_server()));
   16.29  }
   16.30  
   16.31  MainWindow::~MainWindow()
   16.32  {
   16.33 -    delete ui;
   16.34 +	delete ui;
   16.35  }
   16.36 +
   16.37 +
   16.38 +void MainWindow::roll_all()
   16.39 +{
   16.40 +	for(int i=0; i<dicebox->count() - 1; i++) {
   16.41 +		RollWidget *roll = (RollWidget*)dicebox->itemAt(i)->widget();
   16.42 +		roll->roll();
   16.43 +	}
   16.44 +}
   16.45 +
   16.46 +
   16.47 +void MainWindow::add_dice()
   16.48 +{
   16.49 +	RollWidget *w = new RollWidget;
   16.50 +	dicebox->takeAt(dicebox->count() - 1);
   16.51 +	dicebox->addWidget(w);
   16.52 +	dicebox->addStretch();
   16.53 +
   16.54 +	Roll *roll = new Roll;
   16.55 +	roll->set_sides(4);
   16.56 +	dice.push_back(roll);
   16.57 +	w->set_roll(roll);
   16.58 +}
   16.59 +
   16.60 +void MainWindow::clear_dice()
   16.61 +{
   16.62 +	while(!dicebox->isEmpty()) {
   16.63 +		RollWidget *roll = (RollWidget*)dicebox->takeAt(0)->widget();
   16.64 +		delete roll;
   16.65 +	}
   16.66 +
   16.67 +	for(size_t i=0; i<dice.size(); i++) {
   16.68 +		delete dice[i];
   16.69 +	}
   16.70 +	dice.clear();
   16.71 +}
   16.72 +
   16.73 +void MainWindow::start_client()
   16.74 +{
   16.75 +	Ui::ServerDialog *dlg = new Ui::ServerDialog;
   16.76 +	dlg->setupUi(0);
   16.77 +}
   16.78 +
   16.79 +void MainWindow::start_server()
   16.80 +{
   16.81 +}
    17.1 --- a/src/mainwin.h	Thu Dec 19 13:34:40 2013 +0200
    17.2 +++ b/src/mainwin.h	Sun Dec 22 04:08:50 2013 +0200
    17.3 @@ -1,22 +1,31 @@
    17.4 -#ifndef MAINWIN_H
    17.5 -#define MAINWIN_H
    17.6 +#ifndef MAINWIN_H_
    17.7 +#define MAINWIN_H_
    17.8  
    17.9  #include <QMainWindow>
   17.10 +#include <QVBoxLayout>
   17.11 +#include "rollwidget.h"
   17.12  
   17.13  namespace Ui {
   17.14  class MainWindow;
   17.15  }
   17.16  
   17.17 -class MainWindow : public QMainWindow
   17.18 -{
   17.19 -    Q_OBJECT
   17.20 +class MainWindow : public QMainWindow {
   17.21 +	Q_OBJECT
   17.22 +private:
   17.23 +	Ui::MainWindow *ui;
   17.24 +	QVBoxLayout *dicebox;
   17.25 +
   17.26 +private slots:
   17.27 +	void roll_all();
   17.28 +	void add_dice();
   17.29 +	void clear_dice();
   17.30 +
   17.31 +	void start_client();
   17.32 +	void start_server();
   17.33  
   17.34  public:
   17.35 -    explicit MainWindow(QWidget *parent = 0);
   17.36 -    ~MainWindow();
   17.37 -
   17.38 -private:
   17.39 -    Ui::MainWindow *ui;
   17.40 +	explicit MainWindow(QWidget *parent = 0);
   17.41 +	~MainWindow();
   17.42  };
   17.43  
   17.44 -#endif // MAINWIN_H
   17.45 +#endif	// MAINWIN_H_
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/roll.cc	Sun Dec 22 04:08:50 2013 +0200
    18.3 @@ -0,0 +1,45 @@
    18.4 +#include <stdlib.h>
    18.5 +#include <math.h>
    18.6 +#include "roll.h"
    18.7 +
    18.8 +Roll::Roll(int sides)
    18.9 +{
   18.10 +	this->sides = sides;
   18.11 +	value = 0;
   18.12 +}
   18.13 +
   18.14 +void Roll::set_name(const char *name)
   18.15 +{
   18.16 +	this->name = std::string(name);
   18.17 +}
   18.18 +
   18.19 +void Roll::set_sides(int sides)
   18.20 +{
   18.21 +	this->sides = sides;
   18.22 +}
   18.23 +
   18.24 +void Roll::set_value(int value)
   18.25 +{
   18.26 +	this->value = value;
   18.27 +}
   18.28 +
   18.29 +const char *Roll::get_name() const
   18.30 +{
   18.31 +	return name.c_str();
   18.32 +}
   18.33 +
   18.34 +int Roll::get_sides() const
   18.35 +{
   18.36 +	return sides;
   18.37 +}
   18.38 +
   18.39 +int Roll::get_value() const
   18.40 +{
   18.41 +	return value;
   18.42 +}
   18.43 +
   18.44 +int Roll::roll()
   18.45 +{
   18.46 +	value = (int)floor((double)sides * (double)rand() / (double)RAND_MAX);
   18.47 +	return value;
   18.48 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/roll.h	Sun Dec 22 04:08:50 2013 +0200
    19.3 @@ -0,0 +1,26 @@
    19.4 +#ifndef ROLL_H_
    19.5 +#define ROLL_H_
    19.6 +
    19.7 +#include <string>
    19.8 +
    19.9 +class Roll {
   19.10 +private:
   19.11 +	int sides;
   19.12 +	int value;
   19.13 +	std::string name;
   19.14 +
   19.15 +public:
   19.16 +	explicit Roll(int sides = 20);
   19.17 +
   19.18 +	void set_name(const char *name);
   19.19 +	void set_sides(int sides);
   19.20 +	void set_value(int value);
   19.21 +
   19.22 +	const char *get_name() const;
   19.23 +	int get_sides() const;
   19.24 +	int get_value() const;
   19.25 +
   19.26 +	int roll();
   19.27 +};
   19.28 +
   19.29 +#endif	// ROLL_H_
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/rollwidget.cc	Sun Dec 22 04:08:50 2013 +0200
    20.3 @@ -0,0 +1,73 @@
    20.4 +#include <stdio.h>
    20.5 +#include "rollwidget.h"
    20.6 +#include <QHBoxLayout>
    20.7 +#include <QComboBox>
    20.8 +#include <QLineEdit>
    20.9 +#include <QPushButton>
   20.10 +
   20.11 +static struct {
   20.12 +	const char *name;
   20.13 +	int sides;
   20.14 +} dice_types[] = {
   20.15 +	{ "d4", 4 },
   20.16 +	{ "d6", 6 },
   20.17 +	{ "d8", 8 },
   20.18 +	{ "d10", 10 },
   20.19 +	{ "d12", 12 },
   20.20 +	{ "d20", 20 },
   20.21 +	{ "d100", 100 },
   20.22 +	{ 0, 0 }
   20.23 +};
   20.24 +
   20.25 +RollWidget::RollWidget(QWidget *parent) :
   20.26 +	QWidget(parent)
   20.27 +{
   20.28 +	dice = 0;
   20.29 +
   20.30 +	QHBoxLayout *hbox = new QHBoxLayout(this);
   20.31 +
   20.32 +	cmb_type = new QComboBox;
   20.33 +	for(int i=0; dice_types[i].name; i++) {
   20.34 +		char buf[64];
   20.35 +		sprintf(buf, ":/data/dice/%s.png", dice_types[i].name);
   20.36 +		cmb_type->addItem(QIcon(buf), dice_types[i].name);
   20.37 +	}
   20.38 +	hbox->addWidget(cmb_type);
   20.39 +
   20.40 +	QPushButton *bn_roll = new QPushButton("roll");
   20.41 +	hbox->addWidget(bn_roll);
   20.42 +	connect(bn_roll, SIGNAL(clicked()), this, SLOT(roll()));
   20.43 +
   20.44 +	tx_res = new QLineEdit;
   20.45 +	tx_res->setReadOnly(true);
   20.46 +	hbox->addWidget(tx_res);
   20.47 +
   20.48 +	QPushButton *bn_rm = new QPushButton("remove");
   20.49 +	hbox->addWidget(bn_rm);
   20.50 +}
   20.51 +
   20.52 +void RollWidget::set_roll(Roll *roll)
   20.53 +{
   20.54 +	dice = roll;
   20.55 +}
   20.56 +
   20.57 +Roll *RollWidget::get_roll() const
   20.58 +{
   20.59 +	return dice;
   20.60 +}
   20.61 +
   20.62 +
   20.63 +void RollWidget::roll()
   20.64 +{
   20.65 +	if(!dice) return;
   20.66 +
   20.67 +	int sel = cmb_type->currentIndex();
   20.68 +	dice->set_sides(dice_types[sel].sides);
   20.69 +	int value = dice->roll();
   20.70 +
   20.71 +	QString text;
   20.72 +	text.setNum(value);
   20.73 +	tx_res->setText(text);
   20.74 +
   20.75 +	emit value_changed(value);
   20.76 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/src/rollwidget.h	Sun Dec 22 04:08:50 2013 +0200
    21.3 @@ -0,0 +1,29 @@
    21.4 +#ifndef ROLLWIDGET_H
    21.5 +#define ROLLWIDGET_H
    21.6 +
    21.7 +#include <QWidget>
    21.8 +#include <QComboBox>
    21.9 +#include "roll.h"
   21.10 +
   21.11 +class RollWidget : public QWidget
   21.12 +{
   21.13 +	Q_OBJECT
   21.14 +private:
   21.15 +	Roll *dice;
   21.16 +	QComboBox *cmb_type;
   21.17 +	QLineEdit *tx_res;
   21.18 +
   21.19 +public:
   21.20 +	explicit RollWidget(QWidget *parent = 0);
   21.21 +
   21.22 +	void set_roll(Roll *roll);
   21.23 +	Roll *get_roll() const;
   21.24 +
   21.25 +signals:
   21.26 +	void value_changed(int val);
   21.27 +
   21.28 +public slots:
   21.29 +	void roll();
   21.30 +};
   21.31 +
   21.32 +#endif // ROLLWIDGET_H
    22.1 --- a/ui/mainwin.ui	Thu Dec 19 13:34:40 2013 +0200
    22.2 +++ b/ui/mainwin.ui	Sun Dec 22 04:08:50 2013 +0200
    22.3 @@ -6,8 +6,8 @@
    22.4     <rect>
    22.5      <x>0</x>
    22.6      <y>0</y>
    22.7 -    <width>938</width>
    22.8 -    <height>727</height>
    22.9 +    <width>697</width>
   22.10 +    <height>530</height>
   22.11     </rect>
   22.12    </property>
   22.13    <property name="windowTitle">
   22.14 @@ -16,6 +16,52 @@
   22.15    <widget class="QWidget" name="centralWidget">
   22.16     <layout class="QVBoxLayout" name="verticalLayout">
   22.17      <item>
   22.18 +     <layout class="QHBoxLayout" name="horizontalLayout">
   22.19 +      <item>
   22.20 +       <widget class="QPushButton" name="bn_add">
   22.21 +        <property name="text">
   22.22 +         <string>Add</string>
   22.23 +        </property>
   22.24 +        <property name="icon">
   22.25 +         <iconset resource="../qnetdice.qrc">
   22.26 +          <normaloff>:/data/icons/edit-add-2.png</normaloff>:/data/icons/edit-add-2.png</iconset>
   22.27 +        </property>
   22.28 +       </widget>
   22.29 +      </item>
   22.30 +      <item>
   22.31 +       <widget class="QPushButton" name="bn_clear">
   22.32 +        <property name="text">
   22.33 +         <string>Clear</string>
   22.34 +        </property>
   22.35 +        <property name="icon">
   22.36 +         <iconset resource="../qnetdice.qrc">
   22.37 +          <normaloff>:/data/icons/edit-clear-2.png</normaloff>:/data/icons/edit-clear-2.png</iconset>
   22.38 +        </property>
   22.39 +       </widget>
   22.40 +      </item>
   22.41 +      <item>
   22.42 +       <spacer name="horizontalSpacer_2">
   22.43 +        <property name="orientation">
   22.44 +         <enum>Qt::Horizontal</enum>
   22.45 +        </property>
   22.46 +        <property name="sizeHint" stdset="0">
   22.47 +         <size>
   22.48 +          <width>40</width>
   22.49 +          <height>20</height>
   22.50 +         </size>
   22.51 +        </property>
   22.52 +       </spacer>
   22.53 +      </item>
   22.54 +      <item>
   22.55 +       <widget class="QPushButton" name="bn_roll_all">
   22.56 +        <property name="text">
   22.57 +         <string>Roll all</string>
   22.58 +        </property>
   22.59 +       </widget>
   22.60 +      </item>
   22.61 +     </layout>
   22.62 +    </item>
   22.63 +    <item>
   22.64       <widget class="QScrollArea" name="sarea_main">
   22.65        <property name="widgetResizable">
   22.66         <bool>true</bool>
   22.67 @@ -25,8 +71,8 @@
   22.68          <rect>
   22.69           <x>0</x>
   22.70           <y>0</y>
   22.71 -         <width>918</width>
   22.72 -         <height>594</height>
   22.73 +         <width>677</width>
   22.74 +         <height>383</height>
   22.75          </rect>
   22.76         </property>
   22.77        </widget>
   22.78 @@ -39,8 +85,8 @@
   22.79      <rect>
   22.80       <x>0</x>
   22.81       <y>0</y>
   22.82 -     <width>938</width>
   22.83 -     <height>38</height>
   22.84 +     <width>697</width>
   22.85 +     <height>23</height>
   22.86      </rect>
   22.87     </property>
   22.88     <widget class="QMenu" name="menu_file">
   22.89 @@ -51,9 +97,9 @@
   22.90      <addaction name="action_connect"/>
   22.91      <addaction name="separator"/>
   22.92      <addaction name="action_add_die"/>
   22.93 +    <addaction name="action_add_dice"/>
   22.94      <addaction name="separator"/>
   22.95      <addaction name="action_quit"/>
   22.96 -    <addaction name="action_add_dice"/>
   22.97     </widget>
   22.98     <widget class="QMenu" name="menu_help">
   22.99      <property name="title">
  22.100 @@ -74,7 +120,6 @@
  22.101     <addaction name="action_start_server"/>
  22.102     <addaction name="action_connect"/>
  22.103     <addaction name="action_add_die"/>
  22.104 -   <addaction name="action_add_dice"/>
  22.105    </widget>
  22.106    <widget class="QStatusBar" name="stautsbar"/>
  22.107    <action name="action_start_server">
  22.108 @@ -98,6 +143,10 @@
  22.109     </property>
  22.110    </action>
  22.111    <action name="action_add_die">
  22.112 +   <property name="icon">
  22.113 +    <iconset resource="../qnetdice.qrc">
  22.114 +     <normaloff>:/data/icons/edit-add-2.png</normaloff>:/data/icons/edit-add-2.png</iconset>
  22.115 +   </property>
  22.116     <property name="text">
  22.117      <string>&amp;Add die</string>
  22.118     </property>
  22.119 @@ -109,6 +158,8 @@
  22.120    </action>
  22.121   </widget>
  22.122   <layoutdefault spacing="6" margin="11"/>
  22.123 - <resources/>
  22.124 + <resources>
  22.125 +  <include location="../qnetdice.qrc"/>
  22.126 + </resources>
  22.127   <connections/>
  22.128  </ui>
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/ui/server.ui	Sun Dec 22 04:08:50 2013 +0200
    23.3 @@ -0,0 +1,132 @@
    23.4 +<?xml version="1.0" encoding="UTF-8"?>
    23.5 +<ui version="4.0">
    23.6 + <class>ServerDialog</class>
    23.7 + <widget class="QDialog" name="ServerDialog">
    23.8 +  <property name="geometry">
    23.9 +   <rect>
   23.10 +    <x>0</x>
   23.11 +    <y>0</y>
   23.12 +    <width>378</width>
   23.13 +    <height>233</height>
   23.14 +   </rect>
   23.15 +  </property>
   23.16 +  <property name="windowTitle">
   23.17 +   <string>Start server</string>
   23.18 +  </property>
   23.19 +  <layout class="QVBoxLayout" name="verticalLayout">
   23.20 +   <item>
   23.21 +    <layout class="QFormLayout" name="formLayout">
   23.22 +     <item row="0" column="0">
   23.23 +      <widget class="QLabel" name="label_2">
   23.24 +       <property name="text">
   23.25 +        <string>Port</string>
   23.26 +       </property>
   23.27 +       <property name="alignment">
   23.28 +        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
   23.29 +       </property>
   23.30 +      </widget>
   23.31 +     </item>
   23.32 +     <item row="0" column="1">
   23.33 +      <widget class="QLineEdit" name="tx_port"/>
   23.34 +     </item>
   23.35 +     <item row="1" column="0">
   23.36 +      <widget class="QLabel" name="label">
   23.37 +       <property name="text">
   23.38 +        <string>Password</string>
   23.39 +       </property>
   23.40 +       <property name="alignment">
   23.41 +        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
   23.42 +       </property>
   23.43 +      </widget>
   23.44 +     </item>
   23.45 +     <item row="1" column="1">
   23.46 +      <widget class="QLineEdit" name="tx_passwd">
   23.47 +       <property name="echoMode">
   23.48 +        <enum>QLineEdit::PasswordEchoOnEdit</enum>
   23.49 +       </property>
   23.50 +      </widget>
   23.51 +     </item>
   23.52 +    </layout>
   23.53 +   </item>
   23.54 +   <item>
   23.55 +    <spacer name="verticalSpacer">
   23.56 +     <property name="orientation">
   23.57 +      <enum>Qt::Vertical</enum>
   23.58 +     </property>
   23.59 +     <property name="sizeHint" stdset="0">
   23.60 +      <size>
   23.61 +       <width>20</width>
   23.62 +       <height>113</height>
   23.63 +      </size>
   23.64 +     </property>
   23.65 +    </spacer>
   23.66 +   </item>
   23.67 +   <item>
   23.68 +    <layout class="QHBoxLayout" name="horizontalLayout">
   23.69 +     <item>
   23.70 +      <widget class="QPushButton" name="pushButton_2">
   23.71 +       <property name="text">
   23.72 +        <string>&amp;Cancel</string>
   23.73 +       </property>
   23.74 +      </widget>
   23.75 +     </item>
   23.76 +     <item>
   23.77 +      <spacer name="horizontalSpacer">
   23.78 +       <property name="orientation">
   23.79 +        <enum>Qt::Horizontal</enum>
   23.80 +       </property>
   23.81 +       <property name="sizeHint" stdset="0">
   23.82 +        <size>
   23.83 +         <width>40</width>
   23.84 +         <height>20</height>
   23.85 +        </size>
   23.86 +       </property>
   23.87 +      </spacer>
   23.88 +     </item>
   23.89 +     <item>
   23.90 +      <widget class="QPushButton" name="pushButton">
   23.91 +       <property name="text">
   23.92 +        <string>&amp;Start Server</string>
   23.93 +       </property>
   23.94 +      </widget>
   23.95 +     </item>
   23.96 +    </layout>
   23.97 +   </item>
   23.98 +  </layout>
   23.99 + </widget>
  23.100 + <resources/>
  23.101 + <connections>
  23.102 +  <connection>
  23.103 +   <sender>pushButton</sender>
  23.104 +   <signal>clicked()</signal>
  23.105 +   <receiver>ServerDialog</receiver>
  23.106 +   <slot>accept()</slot>
  23.107 +   <hints>
  23.108 +    <hint type="sourcelabel">
  23.109 +     <x>315</x>
  23.110 +     <y>207</y>
  23.111 +    </hint>
  23.112 +    <hint type="destinationlabel">
  23.113 +     <x>276</x>
  23.114 +     <y>139</y>
  23.115 +    </hint>
  23.116 +   </hints>
  23.117 +  </connection>
  23.118 +  <connection>
  23.119 +   <sender>pushButton_2</sender>
  23.120 +   <signal>clicked()</signal>
  23.121 +   <receiver>ServerDialog</receiver>
  23.122 +   <slot>reject()</slot>
  23.123 +   <hints>
  23.124 +    <hint type="sourcelabel">
  23.125 +     <x>70</x>
  23.126 +     <y>204</y>
  23.127 +    </hint>
  23.128 +    <hint type="destinationlabel">
  23.129 +     <x>23</x>
  23.130 +     <y>137</y>
  23.131 +    </hint>
  23.132 +   </hints>
  23.133 +  </connection>
  23.134 + </connections>
  23.135 +</ui>