[prev in list] [next in list] [prev in thread] [next in thread]
List: atlantik-devel
Subject: [atlantik-cvs] CVS: kdegames/atlantik/client tokenwidget.cpp,NONE,1.1 tokenwidget.h,NONE,1.1 Makefil
From: kde () office ! kde ! org
Date: 2002-12-19 3:11:10
[Download RAW message or body]
Update of /home/kde/kdegames/atlantik/client
In directory office:/tmp/cvs-serv26460/client
Modified Files:
Makefile.am atlantik.cpp main.h selectconfiguration_widget.cpp
selectconfiguration_widget.h
Added Files:
tokenwidget.cpp tokenwidget.h
Log Message:
support for custom tokens
--- NEW FILE: tokenwidget.cpp ---
// Copyright (c) 2002 Rob Kaper <cap@capsi.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
#include <qlayout.h>
#include <qlabel.h>
#include <kdialog.h>
#include <kdiroperator.h>
#include <kfileiconview.h>
#include <kfileview.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kurl.h>
#include "tokenwidget.moc"
TokenWidget::TokenWidget(QWidget *parent, const char *name) : QWidget(parent, name)
{
setCaption(i18n("Select token"));
m_mainLayout = new QVBoxLayout(this, KDialog::marginHint());
Q_CHECK_PTR(m_mainLayout);
QLabel *label = new QLabel(i18n("Select a token:"), this);
m_mainLayout->addWidget(label);
KURL startDir(locate("appdata", "themes/default/tokens/"));
KFileIconView *view = new KFileIconView( this , "fileIconView");
m_mainLayout->addWidget(view);
view->setMinimumSize(250, 250);
KDirOperator *kdirop = new KDirOperator( startDir, this );
m_mainLayout->addWidget(kdirop);
connect( kdirop, SIGNAL( fileSelected( const KFileItem * )), SLOT( slotIconSelected( \
const KFileItem * ))); connect( kdirop, SIGNAL( finishedLoading() ), view, SLOT( \
showPreviews() ));
kdirop->setView( view );
}
void TokenWidget::slotIconSelected(const KFileItem *item)
{
emit iconSelected(item->name());
}
--- NEW FILE: tokenwidget.h ---
// Copyright (c) 2002 Rob Kaper <cap@capsi.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
#ifndef ATLANTIK_TOKENWIDGET_H
#define ATLANTIK_TOKENWIDGET_H
#include <qwidget.h>
class QVBoxLayout;
class KFileItem;
class TokenWidget : public QWidget
{
Q_OBJECT
public:
TokenWidget(QWidget *parent, const char *name=0);
public slots:
void slotIconSelected(const KFileItem *item);
signals:
void iconSelected(const QString &name);
private:
QVBoxLayout *m_mainLayout;
};
#endif
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/Makefile.am,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- Makefile.am 9 Jul 2002 19:08:47 -0000 1.38
+++ Makefile.am 19 Dec 2002 03:11:07 -0000 1.39
@@ -5,7 +5,7 @@
atlantik_SOURCES = atlantik.cpp configdlg.cpp main.cpp monopigator.cpp \
selectconfiguration_widget.cpp selectgame_widget.cpp \
- selectserver_widget.cpp
+ selectserver_widget.cpp tokenwidget.cpp
KDE_ICON = atlantik
Index: atlantik.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.cpp,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -d -r1.127 -r1.128
--- atlantik.cpp 19 Dec 2002 00:37:33 -0000 1.127
+++ atlantik.cpp 19 Dec 2002 03:11:07 -0000 1.128
@@ -294,6 +294,7 @@
connect(m_selectConfiguration, SIGNAL(startGame()), m_atlantikNetwork, \
SLOT(startGame())); connect(m_selectConfiguration, SIGNAL(leaveGame()), \
m_atlantikNetwork, SLOT(leaveGame())); connect(m_selectConfiguration, \
SIGNAL(buttonCommand(QString)), m_atlantikNetwork, SLOT(writeData(QString))); \
+ connect(m_selectConfiguration, SIGNAL(iconSelected(const QString &)), \
m_atlantikNetwork, SLOT(setImage(const QString &))); }
void Atlantik::initBoard()
Index: main.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/main.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- main.h 29 Nov 2002 04:27:31 -0000 1.27
+++ main.h 19 Dec 2002 03:11:07 -0000 1.28
@@ -18,7 +18,7 @@
#define ATLANTIK_MAIN_H
#define ATLANTIK_VERSION 060
-#define ATLANTIK_VERSION_STRING "0.6.0 (CVS >= 20021129)"
+#define ATLANTIK_VERSION_STRING "0.6.0 (CVS >= 20021219)"
#define ATLANTIK_VERSION_MAJOR 0
#define ATLANTIK_VERSION_MINOR 6
#define ATLANTIK_VERSION_RELEASE 0
Index: selectconfiguration_widget.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectconfiguration_widget.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- selectconfiguration_widget.cpp 11 Sep 2002 01:40:59 -0000 1.26
+++ selectconfiguration_widget.cpp 19 Dec 2002 03:11:07 -0000 1.27
@@ -25,11 +25,14 @@
#include <klocale.h>
#include <kiconloader.h>
#include <kmessagebox.h>
-
+
+#include "tokenwidget.h"
#include "selectconfiguration_widget.moc"
SelectConfiguration::SelectConfiguration(QWidget *parent, const char *name) : \
QWidget(parent, name) {
+ m_tokenWidget = 0;
+
m_mainLayout = new QVBoxLayout(this, KDialog::marginHint());
Q_CHECK_PTR(m_mainLayout);
@@ -37,7 +40,6 @@
m_playerBox = new QVGroupBox(i18n("Player List"), this, "playerBox");
m_mainLayout->addWidget(m_playerBox);
- // List of players
m_playerList = new KListView(m_playerBox, "m_playerList");
m_playerList->addColumn(QString(i18n("Id")));
m_playerList->addColumn(QString(i18n("Name")));
@@ -48,26 +50,31 @@
connect(m_playerList, SIGNAL(doubleClicked(QListViewItem *)), this, \
SLOT(connectClicked()));
+ // Player buttons.
+ QHBoxLayout *playerButtons = new QHBoxLayout(this, 0, KDialog::spacingHint());
+ m_mainLayout->addItem(playerButtons);
+
+ playerButtons->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, \
QSizePolicy::Minimum)); +
+ m_tokenButton = new KPushButton(SmallIcon("personal"), i18n("Select token"), this);
+ playerButtons->addWidget(m_tokenButton);
+
+ connect(m_tokenButton, SIGNAL(clicked()), this, SLOT(slotTokenButtonClicked()));
+
// Game configuration.
m_configBox = new QVGroupBox(i18n("Game Configuration"), this, "configBox");
m_mainLayout->addWidget(m_configBox);
- QHBoxLayout *buttonBox = new QHBoxLayout(this, 0, KDialog::spacingHint());
- m_mainLayout->addItem(buttonBox);
+ // Server buttons.
+ QHBoxLayout *serverButtons = new QHBoxLayout(this, 0, KDialog::spacingHint());
+ m_mainLayout->addItem(serverButtons);
m_backButton = new KPushButton(SmallIcon("back"), i18n("Leave Game"), this);
- buttonBox->addWidget(m_backButton);
+ serverButtons->addWidget(m_backButton);
connect(m_backButton, SIGNAL(clicked()), this, SIGNAL(leaveGame()));
- buttonBox->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, \
QSizePolicy::Minimum));
-
- m_connectButton = new KPushButton(SmallIcon("forward"), i18n("Start Game"), this);
- buttonBox->addWidget(m_connectButton);
-
- connect(m_connectButton, SIGNAL(clicked()), this, SLOT(connectClicked()));
-
- // Status indicator
+ // Status indicator.
status_label = new QLabel(this);
status_label->setText(i18n("Retrieving configuration list..."));
m_mainLayout->addWidget(status_label);
@@ -126,6 +133,17 @@
emit startGame();
}
+void SelectConfiguration::slotTokenButtonClicked()
+{
+ if (m_tokenWidget)
+ return;
+
+ m_tokenWidget = new TokenWidget(0);
+ m_tokenWidget->show();
+
+ connect(m_tokenWidget, SIGNAL(iconSelected(const QString &)), this, \
SLOT(slotTokenSelected(const QString &))); +}
+
void SelectConfiguration::slotClicked()
{
delete m_messageBox;
@@ -133,6 +151,14 @@
m_configBox->setEnabled(true);
m_connectButton->setEnabled(true);
status_label->setEnabled(true);
+}
+
+void SelectConfiguration::slotTokenSelected(const QString &name)
+{
+ emit iconSelected(name);
+ m_tokenWidget->close();
+// m_tokenWidget->deleteLater(); // FIXME: crashes?
+ m_tokenWidget = 0;
}
void SelectConfiguration::gameOption(QString title, QString type, QString value, \
QString edit, QString command)
Index: selectconfiguration_widget.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/selectconfiguration_widget.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- selectconfiguration_widget.h 1 Aug 2002 15:16:25 -0000 1.12
+++ selectconfiguration_widget.h 19 Dec 2002 03:11:07 -0000 1.13
@@ -27,6 +27,8 @@
class QCheckBox;
+class TokenWidget;
+
class SelectConfiguration : public QWidget
{
Q_OBJECT
@@ -47,15 +49,19 @@
private slots:
void connectClicked();
+ void slotTokenButtonClicked();
void slotClicked();
+ void slotTokenSelected(const QString &name);
void gameOption(QString title, QString type, QString value, QString edit, QString \
command); void optionChanged();
+
signals:
void startGame();
void leaveGame();
void joinConfiguration(int configurationId);
void newConfiguration();
void buttonCommand(QString);
+ void iconSelected(const QString &);
// void statusChanged();
private:
@@ -63,9 +69,10 @@
QLabel *status_label;
QVGroupBox *m_playerBox, *m_configBox, *m_messageBox;
KListView *m_playerList;
- KPushButton *m_backButton, *m_connectButton;
+ KPushButton *m_backButton, *m_connectButton, *m_tokenButton;
QMap <QObject *, QString> m_optionCommandMap;
QMap <QString, QCheckBox *> m_checkBoxMap;
+ TokenWidget *m_tokenWidget;
};
#endif
_______________________________________________
atlantik-cvs mailing list
atlantik-cvs@mail.kde.org
http://mail.kde.org/mailman/listinfo/atlantik-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic