• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

  • libtdegames
  • kgame
  • dialogs
kgameerrordialog.cpp
1 /*
2  This file is part of the TDE games library
3  Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
4  Copyright (C) 2001 Martin Heni (martin@heni-online.de)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include <tdemessagebox.h>
22 #include <tdelocale.h>
23 #include <kdebug.h>
24 
25 #include "kgame.h"
26 
27 #include "kgameerrordialog.h"
28 
29 class KGameErrorDialogPrivate
30 {
31 public:
32  KGameErrorDialogPrivate()
33  {
34  mGame = 0;
35  }
36 
37  const KGame* mGame;
38 };
39 
40 KGameErrorDialog::KGameErrorDialog(TQWidget* parent) : TQObject(parent)
41 {
42  d = new KGameErrorDialogPrivate;
43 }
44 
45 KGameErrorDialog::~KGameErrorDialog()
46 {
47  delete d;
48 }
49 
50 void KGameErrorDialog::setKGame(const KGame* g)
51 {
52  slotUnsetKGame();
53  d->mGame = g;
54 
55  connect(d->mGame, TQ_SIGNAL(destroyed()), this, TQ_SLOT(slotUnsetKGame()));
56 
57 // the error signals:
58  connect(d->mGame, TQ_SIGNAL(signalNetworkErrorMessage(int, TQString)),
59  this, TQ_SLOT(slotError(int, TQString)));
60  connect(d->mGame, TQ_SIGNAL(signalConnectionBroken()),
61  this, TQ_SLOT(slotServerConnectionLost()));
62  connect(d->mGame, TQ_SIGNAL(signalClientDisconnected(TQ_UINT32,bool)),
63  this, TQ_SLOT(slotClientConnectionLost(TQ_UINT32,bool)));
64 }
65 
66 void KGameErrorDialog::slotUnsetKGame()
67 {
68  if (d->mGame) {
69  disconnect(d->mGame, 0, this, 0);
70  }
71  d->mGame = 0;
72 }
73 
74 void KGameErrorDialog::error(const TQString& errorText, TQWidget* parent)
75 { KMessageBox::error(parent, errorText); }
76 
77 void KGameErrorDialog::slotServerConnectionLost()
78 {
79 // TODO: add IP/port of the server
80  TQString message = i18n("Connection to the server has been lost!");
81  error(message, (TQWidget*)parent());
82 }
83 
84 void KGameErrorDialog::slotClientConnectionLost(TQ_UINT32 /*id*/,bool)
85 {
86 //TODO: add IP/port of the client
87  TQString message;
88 // if (c) {
89 // message = i18n("Connection to client has been lost!\nID: %1\nIP: %2").arg(c->id()).arg(c->IP());
90 // } else {
91 // message = i18n("Connection to client has been lost!");
92 // }
93  message = i18n("Connection to client has been lost!");
94  error(message, (TQWidget*)parent());
95 }
96 
97 void KGameErrorDialog::slotError(int errorNo, TQString text)
98 {
99  TQString message = i18n("Received a network error!\nError number: %1\nError message: %2").arg(errorNo).arg(text);
100  error(message, (TQWidget*)parent());
101 }
102 
103 void KGameErrorDialog::connectionError(TQString s)
104 {
105  TQString message;
106  if (s.isNull()) {
107  message = i18n("No connection could be created.");
108  } else {
109  message = i18n("No connection could be created.\nThe error message was:\n%1").arg(s);
110  }
111  error(message, (TQWidget*)parent());
112 }
113 
114 
115 
116 // should become the real dialog - currently we just use messageboxes
117 // -> maybe unused forever
118 KGameErrorMessageDialog::KGameErrorMessageDialog(TQWidget* parent)
119  : KDialogBase(Plain, i18n("Error"), Ok, Ok, parent, 0, true, true)
120 {
121 }
122 
123 KGameErrorMessageDialog::~KGameErrorMessageDialog()
124 {
125 }
126 
127 
128 
129 #include "kgameerrordialog.moc"
KGameErrorDialog::slotClientConnectionLost
void slotClientConnectionLost(TQ_UINT32 clientID, bool broken)
The connection to a client has been lost by accident.
Definition: kgameerrordialog.cpp:84
KGameErrorDialog::slotServerConnectionLost
void slotServerConnectionLost()
The connection to the KMessageServer has been lost.
Definition: kgameerrordialog.cpp:77
KGameErrorDialog::connectionError
void connectionError(TQString s=TQString())
KGame couldn't establish a connection.
Definition: kgameerrordialog.cpp:103
KGameErrorDialog::slotUnsetKGame
void slotUnsetKGame()
Unsets a KGame which has been set using setKGame before.
Definition: kgameerrordialog.cpp:66
KGameErrorDialog::setKGame
void setKGame(const KGame *g)
Automatically connects the KGame object to all error dependant slots.
Definition: kgameerrordialog.cpp:50
KGame
The main KDE game object.
Definition: kgame.h:63

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.9.1
This website is maintained by Timothy Pearson.