2
This file is part of the KDE games library
3
Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
4
Copyright (C) 2001 Martin Heni (kde at heni-online.de)
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.
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.
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.
21
#include "kgameerrordialog.h"
23
#include <kmessagebox.h>
29
class KGameErrorDialogPrivate
32
KGameErrorDialogPrivate()
40
KGameErrorDialog::KGameErrorDialog(QWidget* parent) : QObject(parent)
42
d = new KGameErrorDialogPrivate;
45
KGameErrorDialog::~KGameErrorDialog()
50
void KGameErrorDialog::setKGame(const KGame* g)
55
connect(d->mGame, SIGNAL(destroyed()), this, SLOT(slotUnsetKGame()));
58
connect(d->mGame, SIGNAL(signalNetworkErrorMessage(int,QString)),
59
this, SLOT(slotError(int,QString)));
60
connect(d->mGame, SIGNAL(signalConnectionBroken()),
61
this, SLOT(slotServerConnectionLost()));
62
connect(d->mGame, SIGNAL(signalClientDisconnected(quint32,bool)),
63
this, SLOT(slotClientConnectionLost(quint32,bool)));
66
void KGameErrorDialog::slotUnsetKGame()
69
disconnect(d->mGame, 0, this, 0);
74
void KGameErrorDialog::error(const QString& errorText, QWidget* parent)
75
{ KMessageBox::error(parent, errorText); }
77
void KGameErrorDialog::slotServerConnectionLost()
79
// TODO: add IP/port of the server
80
QString message = i18n("Connection to the server has been lost!");
81
error(message, (QWidget*)parent());
84
void KGameErrorDialog::slotClientConnectionLost(quint32 /*id*/,bool)
86
//TODO: add IP/port of the client
89
// message = i18n("Connection to client has been lost!\nID: %1\nIP: %2").arg(c->id()).arg(c->IP());
91
// message = i18n("Connection to client has been lost!");
93
message = i18n("Connection to client has been lost!");
94
error(message, (QWidget*)parent());
97
void KGameErrorDialog::slotError(int errorNo, const QString& text)
99
QString message = i18n("Received a network error!\nError number: %1\nError message: %2", errorNo, text);
100
error(message, (QWidget*)parent());
103
void KGameErrorDialog::connectionError(const QString& s)
107
message = i18n("No connection could be created.");
109
message = i18n("No connection could be created.\nThe error message was:\n%1", s);
111
error(message, (QWidget*)parent());
116
// should become the real dialog - currently we just use messageboxes
117
// -> maybe unused forever
118
KGameErrorMessageDialog::KGameErrorMessageDialog(QWidget* parent)
121
setCaption(i18n("Error"));
123
setDefaultButton(Ok);
125
showButtonSeparator(true);
128
KGameErrorMessageDialog::~KGameErrorMessageDialog()
134
#include "kgameerrordialog.moc"