kgameerrordialog.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <kmessagebox.h>
00022 #include <klocale.h>
00023 #include <kdebug.h>
00024
00025 #include "kgame.h"
00026
00027 #include "kgameerrordialog.h"
00028
00029 class KGameErrorDialogPrivate
00030 {
00031 public:
00032 KGameErrorDialogPrivate()
00033 {
00034 mGame = 0;
00035 }
00036
00037 const KGame* mGame;
00038 };
00039
00040 KGameErrorDialog::KGameErrorDialog(QWidget* parent) : QObject(parent)
00041 {
00042 d = new KGameErrorDialogPrivate;
00043 }
00044
00045 KGameErrorDialog::~KGameErrorDialog()
00046 {
00047 delete d;
00048 }
00049
00050 void KGameErrorDialog::setKGame(const KGame* g)
00051 {
00052 slotUnsetKGame();
00053 d->mGame = g;
00054
00055 connect(d->mGame, SIGNAL(destroyed()), this, SLOT(slotUnsetKGame()));
00056
00057
00058 connect(d->mGame, SIGNAL(signalNetworkErrorMessage(int, QString)),
00059 this, SLOT(slotError(int, QString)));
00060 connect(d->mGame, SIGNAL(signalConnectionBroken()),
00061 this, SLOT(slotServerConnectionLost()));
00062 connect(d->mGame, SIGNAL(signalClientDisconnected(Q_UINT32,bool)),
00063 this, SLOT(slotClientConnectionLost(Q_UINT32,bool)));
00064 }
00065
00066 void KGameErrorDialog::slotUnsetKGame()
00067 {
00068 if (d->mGame) {
00069 disconnect(d->mGame, 0, this, 0);
00070 }
00071 d->mGame = 0;
00072 }
00073
00074 void KGameErrorDialog::error(const QString& errorText, QWidget* parent)
00075 { KMessageBox::error(parent, errorText); }
00076
00077 void KGameErrorDialog::slotServerConnectionLost()
00078 {
00079
00080 QString message = i18n("Connection to the server has been lost!");
00081 error(message, (QWidget*)parent());
00082 }
00083
00084 void KGameErrorDialog::slotClientConnectionLost(Q_UINT32 ,bool)
00085 {
00086
00087 QString message;
00088
00089
00090
00091
00092
00093 message = i18n("Connection to client has been lost!");
00094 error(message, (QWidget*)parent());
00095 }
00096
00097 void KGameErrorDialog::slotError(int errorNo, QString text)
00098 {
00099 QString message = i18n("Received a network error!\nError number: %1\nError message: %2").arg(errorNo).arg(text);
00100 error(message, (QWidget*)parent());
00101 }
00102
00103 void KGameErrorDialog::connectionError(QString s)
00104 {
00105 QString message;
00106 if (s.isNull()) {
00107 message = i18n("No connection could be created.");
00108 } else {
00109 message = i18n("No connection could be created.\nThe error message was:\n%1").arg(s);
00110 }
00111 error(message, (QWidget*)parent());
00112 }
00113
00114
00115
00116
00117
00118 KGameErrorMessageDialog::KGameErrorMessageDialog(QWidget* parent)
00119 : KDialogBase(Plain, i18n("Error"), Ok, Ok, parent, 0, true, true)
00120 {
00121 }
00122
00123 KGameErrorMessageDialog::~KGameErrorMessageDialog()
00124 {
00125 }
00126
00127
00128
00129 #include "kgameerrordialog.moc"
|