kgamedialogconfig.h

00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
00004     Copyright (C) 2001 Martin Heni (martin@heni-online.de)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License version 2 as published by the Free Software Foundation.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 // NAMING
00022 // please follow these naming rules if you add/change classes:
00023 // the main dialog is named KGameDialog and the base config widget
00024 // KGameDialogConfig. All config widgets are named KGameDialogXYZConfig (where
00025 // XYZ = the name of the config widget, like "general" or "network") and are
00026 // inherited from KGameDialogConfig.
00027 
00028 #ifndef __KGAMEDIALOGCONFIG_H__
00029 #define __KGAMEDIALOGCONFIG_H__
00030 
00031 #include <qwidget.h>
00032 #include <kdemacros.h>
00033 
00034 class QGridLayout;
00035 class QVBoxLayout;
00036 class QListBoxItem;
00037 
00038 class KGame;
00039 class KPlayer;
00040 class KGamePropertyBase;
00041 
00042 class KGameDialogConfigPrivate;
00051 class KDE_EXPORT KGameDialogConfig : public QWidget
00052 {
00053     Q_OBJECT
00054 public:
00055     KGameDialogConfig(QWidget* parent = 0);
00056     virtual ~KGameDialogConfig();
00057 
00065     virtual void submitToKGame(KGame* g, KPlayer* p) = 0;
00066 
00078     virtual void setOwner(KPlayer* p);
00079 
00088     virtual void setKGame(KGame* g);
00089 
00104     virtual void setAdmin(bool admin);
00105 
00112     KGame* game() const;
00113 
00121     KPlayer* owner() const;
00122 
00127     bool admin() const;
00128 
00129 protected:
00130 
00131 private:
00132     KGameDialogConfigPrivate* d;
00133 };
00134 
00143 class KGameDialogGeneralConfigPrivate;
00144 class KGameDialogGeneralConfig : public KGameDialogConfig
00145 {
00146     Q_OBJECT
00147 public:
00163     KGameDialogGeneralConfig(QWidget* parent = 0, bool initializeGUI = true);
00164     virtual ~KGameDialogGeneralConfig();
00165 
00173     virtual void submitToKGame(KGame* g, KPlayer* p);
00174 
00181     virtual void setOwner(KPlayer* p);
00182 
00189     virtual void setKGame(KGame* g);
00190 
00196     virtual void setAdmin(bool admin);
00197 
00198 protected slots:
00199     void slotPropertyChanged(KGamePropertyBase*, KPlayer*);
00200 
00201 protected:
00202     void setPlayerName(const QString& name);
00203 
00204     QString playerName() const;
00205 
00206 private:
00207     KGameDialogGeneralConfigPrivate* d;
00208 };
00209 
00210 class KGameDialogNetworkConfigPrivate;
00211 class KDE_EXPORT KGameDialogNetworkConfig : public KGameDialogConfig
00212 {
00213     Q_OBJECT
00214 public:
00215     KGameDialogNetworkConfig(QWidget* parent = 0);
00216     virtual ~KGameDialogNetworkConfig();
00217 
00218 
00219     void disableInitConnection();
00220 
00228     virtual void submitToKGame(KGame* g, KPlayer* p);
00229 
00230     virtual void setKGame(KGame* g);
00231 
00241     void setDefaultNetworkInfo(const QString& host, unsigned short int port,bool server=true);
00242     
00251     void setDiscoveryInfo(const QString& type, const QString& name=QString::null);
00252     
00253 signals:
00260   void signalServerTypeChanged(int);
00261 
00262 
00263 protected:
00264     void setConnected(bool connected, bool master = false);
00265 
00266 protected slots:
00267     void slotInitConnection();
00268     void slotExitConnection();
00269     void slotConnectionBroken();
00270 
00271 
00272 private:
00273     KGameDialogNetworkConfigPrivate* d;
00274 };
00275 
00276 class KGameDialogMsgServerConfigPrivate;
00277 class KGameDialogMsgServerConfig : public KGameDialogConfig
00278 {
00279     Q_OBJECT
00280 public:
00281     KGameDialogMsgServerConfig(QWidget* parent = 0);
00282     virtual ~KGameDialogMsgServerConfig();
00283 
00284     virtual void submitToKGame(KGame*, KPlayer*) {}
00285 
00286     void setHasMsgServer(bool);
00287 
00288     virtual void setKGame(KGame* g);
00289     virtual void setAdmin(bool);
00290 
00291 protected slots:
00292     void slotChangeMaxClients();
00293     void slotChangeAdmin();
00294     void slotRemoveClient();
00295 
00296 protected:
00297     void removeClient(Q_UINT32 id);
00298 
00299 private:
00300     KGameDialogMsgServerConfigPrivate* d;
00301 };
00302 
00303 class KGameDialogChatConfigPrivate;
00310 class KGameDialogChatConfig : public KGameDialogConfig
00311 {
00312     Q_OBJECT
00313 public:
00314     KGameDialogChatConfig(int chatMsgId, QWidget* parent = 0);
00315     virtual ~KGameDialogChatConfig();
00316 
00317     virtual void setKGame(KGame* g);
00318     virtual void setOwner(KPlayer* p);
00319 
00320     virtual void submitToKGame(KGame* g, KPlayer* p) { Q_UNUSED(g); Q_UNUSED(p); }
00321 
00322 private:
00323     KGameDialogChatConfigPrivate* d;
00324 };
00325 
00330 class KGameDialogConnectionConfigPrivate;
00331 class KGameDialogConnectionConfig : public KGameDialogConfig
00332 {
00333     Q_OBJECT
00334 public:
00335     KGameDialogConnectionConfig(QWidget* parent = 0);
00336     virtual ~KGameDialogConnectionConfig();
00337 
00338     virtual void setKGame(KGame* g);
00339     virtual void setOwner(KPlayer* p);
00340     virtual void setAdmin(bool admin);
00341 
00342     virtual void submitToKGame(KGame* g, KPlayer* p) { Q_UNUSED(g); Q_UNUSED(p); }
00343 
00344 protected:
00349     QListBoxItem* item(KPlayer* p) const;
00350 
00351 protected slots:
00352     void slotKickPlayerOut(QListBoxItem* item);
00353     void slotPropertyChanged(KGamePropertyBase* prop, KPlayer* p);
00354     void slotPlayerLeftGame(KPlayer* p);
00355     void slotPlayerJoinedGame(KPlayer* p);
00356     void slotClearPlayers();
00357 
00358 private:
00359     KGameDialogConnectionConfigPrivate* d;
00360         
00361 };
00362 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys