--- a/QTfrontend/CMakeLists.txt Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/CMakeLists.txt Tue Feb 20 17:50:59 2007 +0000
@@ -46,7 +46,8 @@
netconnectedclient.cpp
newnetclient.cpp
netudpserver.cpp
- netudpwidget.cpp)
+ netudpwidget.cpp
+ chatwidget.cpp)
if (WIN32)
set(hwfr_src ${hwfr_src} res/hedgewars.rc)
@@ -78,7 +79,8 @@
netconnectedclient.h
newnetclient.h
netudpserver.h
- netudpwidget.h)
+ netudpwidget.h
+ chatwidget.h)
set(hwfr_rez
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/chatwidget.cpp Tue Feb 20 17:50:59 2007 +0000
@@ -0,0 +1,35 @@
+#include <QListWidget>
+#include <QLineEdit>
+
+#include "chatwidget.h"
+
+HWChatWidget::HWChatWidget(QWidget* parent) :
+ QWidget(parent),
+ mainLayout(this)
+{
+ mainLayout.setSpacing(1);
+ mainLayout.setMargin(1);
+
+ chatEditLine = new QLineEdit(this);
+ connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
+
+ mainLayout.addWidget(chatEditLine, 1, 0);
+
+ chatText = new QListWidget(this);
+ chatText->setMinimumHeight(10);
+ mainLayout.addWidget(chatText, 0, 0);
+}
+
+void HWChatWidget::returnPressed()
+{
+ emit chatLine(chatEditLine->text());
+ chatEditLine->clear();
+}
+
+void HWChatWidget::onChatStringFromNet(const QStringList& str)
+{
+ QListWidget* w=chatText;
+ w->addItem(str[0]+": "+str[1]);
+ w->scrollToBottom();
+ w->setSelectionMode(QAbstractItemView::NoSelection);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/chatwidget.h Tue Feb 20 17:50:59 2007 +0000
@@ -0,0 +1,33 @@
+#ifndef _CHAT_WIDGET_INCLUDED
+#define _CHAT_WIDGET_INCLUDED
+
+#include <QWidget>
+#include <QString>
+#include <QGridLayout>
+
+class QListWidget;
+class QLineEdit;
+
+class HWChatWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ HWChatWidget(QWidget* parent=0);
+
+ public slots:
+ void onChatStringFromNet(const QStringList& str);
+
+ signals:
+ void chatLine(const QString& str);
+
+ private:
+ QGridLayout mainLayout;
+ QListWidget* chatText;
+ QLineEdit* chatEditLine;
+
+ private slots:
+ void returnPressed();
+};
+
+#endif // _CHAT_WIDGET_INCLUDED
--- a/QTfrontend/hedgewars.pro Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/hedgewars.pro Tue Feb 20 17:50:59 2007 +0000
@@ -37,7 +37,8 @@
netconnectedclient.h \
newnetclient.h \
netudpserver.h \
- netudpwidget.h
+ netudpwidget.h \
+ chatwidget.h
SOURCES += game.cpp \
@@ -64,7 +65,8 @@
netconnectedclient.cpp \
newnetclient.cpp \
netudpserver.cpp \
- netudpwidget.cpp
+ netudpwidget.cpp \
+ chatwidget.cpp
TRANSLATIONS += ../share/hedgewars/Data/Locale/hedgewars_ru.ts
--- a/QTfrontend/hwform.cpp Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/hwform.cpp Tue Feb 20 17:50:59 2007 +0000
@@ -39,6 +39,7 @@
#include "gamecfgwidget.h"
#include "netudpserver.h"
#include "netudpwidget.h"
+#include "chatwidget.h"
HWForm::HWForm(QWidget *parent)
: QMainWindow(parent), pnetserver(0), pUdpServer(0)
@@ -265,11 +266,12 @@
connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &)));
connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)));
- connect(hwnet, SIGNAL(chatStringFromNet(const QStringList&)),
- this, SLOT(onChatStringFromNet(const QStringList&)));
- connect(ui.pageNetGame->chatEditLine, SIGNAL(returnPressed()),
- this, SLOT(chatLineToNet()));
+ connect(hwnet, SIGNAL(chatStringFromNet(const QStringList&)),
+ ui.pageNetGame->pChatWidget, SLOT(onChatStringFromNet(const QStringList&)));
+ connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)),
+ hwnet, SLOT(chatLineToNet(const QString&)));
+
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)),
hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&)));
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)),
@@ -444,17 +446,3 @@
"Hedgewars",
msg);
}
-
-void HWForm::chatLineToNet()
-{
- hwnet->chatLineToNet(ui.pageNetGame->chatEditLine->text());
- ui.pageNetGame->chatEditLine->clear();
-}
-
-void HWForm::onChatStringFromNet(const QStringList& str)
-{
- QListWidget* w=ui.pageNetGame->chatText;
- w->addItem(str[0]+": "+str[1]);
- w->scrollToBottom();
- w->setSelectionMode(QAbstractItemView::NoSelection);
-}
--- a/QTfrontend/hwform.h Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/hwform.h Tue Feb 20 17:50:59 2007 +0000
@@ -75,8 +75,6 @@
void GameStats(char type, const QString & info);
void ForcedDisconnect();
void ShowErrorMessage(const QString &);
- void chatLineToNet();
- void onChatStringFromNet(const QStringList&);
private:
void _NetConnect(const QString & hostName, quint16 port, const QString & nick);
--- a/QTfrontend/netconnectedclient.cpp Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/netconnectedclient.cpp Tue Feb 20 17:50:59 2007 +0000
@@ -88,7 +88,7 @@
qDebug() << QString("CONFIG_PARAM")+delimeter+it.key()+delimeter+it.value().join(QString(delimeter));
}
}
- m_hwserver->sendAll(QString("JOINED")+delimeter+client_nick);
+ m_hwserver->sendOthers(this, QString("JOINED")+delimeter+client_nick);
return;
}
if(client_nick=="") return;
--- a/QTfrontend/netserver.cpp Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/netserver.cpp Tue Feb 20 17:50:59 2007 +0000
@@ -69,6 +69,7 @@
for(QList<QStringList>::iterator tmIt=(*it)->m_teamsCfg.begin(); tmIt!=(*it)->m_teamsCfg.end(); ++tmIt) {
sendOthers(*it, QString("REMOVETEAM:")+delimeter+*(tmIt->begin()) + delimeter + *(tmIt->begin()+1));
}
+ sendOthers(*it, QString("LEFT")+delimeter+client->client_nick);
connclients.erase(it);
//teamChanged();
}
--- a/QTfrontend/newnetclient.cpp Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/newnetclient.cpp Tue Feb 20 17:50:59 2007 +0000
@@ -190,6 +190,12 @@
return;
}
+ if(lst[0]=="LEFT") {
+ if(lst.size()<2) return;
+ qDebug() << "LEFT" << lst[1];
+ return;
+ }
+
if (lst[0] == "CONFIGASKED") {
isChief=true;
ConfigAsked();
--- a/QTfrontend/pages.cpp Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/pages.cpp Tue Feb 20 17:50:59 2007 +0000
@@ -41,6 +41,7 @@
#include "about.h"
#include "fpsedit.h"
#include "netudpwidget.h"
+#include "chatwidget.h"
PageMain::PageMain(QWidget* parent) : QWidget(parent)
{
@@ -511,30 +512,29 @@
QFont * font14 = new QFont("MS Shell Dlg", 14);
QGridLayout * pageLayout = new QGridLayout(this);
pageLayout->setSizeConstraint(QLayout::SetMinimumSize);
-
- chatEditLine = new QLineEdit(this);
- pageLayout->addWidget(chatEditLine, 2, 0);
+ //pageLayout->setSpacing(1);
+ //pageLayout->setMargin(1);
- chatText = new QListWidget(this);
- chatText->setMinimumHeight(10);
- pageLayout->addWidget(chatText, 1, 0);
+ // chatwidget
+ pChatWidget = new HWChatWidget(this);
+ pageLayout->addWidget(pChatWidget, 1, 0);
pGameCFG = new GameCFGWidget(this);
pageLayout->addWidget(pGameCFG, 0, 0);
pNetTeamsWidget = new TeamSelWidget(this);
pNetTeamsWidget->setAcceptOuter(true);
- pageLayout->addWidget(pNetTeamsWidget, 0, 1, 3, 1);
+ pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1);
BtnBack = new QPushButton(this);
BtnBack->setFont(*font14);
BtnBack->setText(QPushButton::tr("Back"));
- pageLayout->addWidget(BtnBack, 3, 0);
+ pageLayout->addWidget(BtnBack, 2, 0);
BtnGo = new QPushButton(this);
BtnGo->setFont(*font14);
BtnGo->setText(QPushButton::tr("Go!"));
- pageLayout->addWidget(BtnGo, 3, 1);
+ pageLayout->addWidget(BtnGo, 2, 1);
}
PageInfo::PageInfo(QWidget* parent) : QWidget(parent)
--- a/QTfrontend/pages.h Tue Feb 20 17:32:25 2007 +0000
+++ b/QTfrontend/pages.h Tue Feb 20 17:50:59 2007 +0000
@@ -41,6 +41,7 @@
class FPSEdit;
class HWNetUdpWidget;
class QTextEdit;
+class HWChatWidget;
class PageMain : public QWidget
{
@@ -195,8 +196,8 @@
QPushButton *BtnBack;
QPushButton *BtnGo;
- QListWidget* chatText;
- QLineEdit* chatEditLine;
+
+ HWChatWidget* pChatWidget;
TeamSelWidget* pNetTeamsWidget;
GameCFGWidget* pGameCFG;