add chat functions

This commit is contained in:
doitux
2007-05-25 00:09:51 +00:00
parent e8d7009106
commit 2333079b13
12 changed files with 58 additions and 8 deletions
+11 -1
View File
@@ -20,12 +20,14 @@
#include "chat.h"
#include "mainwindowimpl.h"
#include "session.h"
using namespace std;
Chat::Chat(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
{
// myW->setChat(this);
myW->setChat(this);
}
@@ -34,3 +36,11 @@ Chat::~Chat()
delete myConfig;
myConfig = 0;
}
void Chat::sendMessage() {
myW->getSession().sendChatMessage(myW->lineEdit_ChatInput->text().toUtf8().constData());
myW->lineEdit_ChatInput->setText("");
}
void Chat::receiveMessage(std::string message) { myW->textBrowser_Chat->append(QString::fromUtf8(message.c_str())); }
+3 -4
View File
@@ -40,10 +40,9 @@ public:
public slots:
public:
signals:
void sendMessage();
void receiveMessage(std::string);
private:
mainWindowImpl *myW;
+13 -1
View File
@@ -558,6 +558,9 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
connect ( horizontalSlider_speed, SIGNAL( valueChanged(int)), this, SLOT ( setGameSpeed(int) ) );
connect ( pushButton_break, SIGNAL( clicked()), this, SLOT ( breakButtonClicked() ) ); // auch wieder starten!!!!
connect( tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( setChatFocus() ) );
connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) );
//Nachrichten Thread-Save
connect(this, SIGNAL(signalRefreshSet()), this, SLOT(refreshSet()));
connect(this, SIGNAL(signalRefreshCash()), this, SLOT(refreshCash()));
@@ -862,7 +865,7 @@ void mainWindowImpl::setSession(boost::shared_ptr<Session> session)
mySession = session;
}
void mainWindowImpl::setLog(Log* l) { myLog = l; }
//refresh-Funktionen
void mainWindowImpl::refreshSet() {
@@ -2506,6 +2509,15 @@ void mainWindowImpl::blinkingStartButtonAnimationAction() {
pushButton_break->setPalette(tempPalette);
}
void mainWindowImpl::sendChatMessage() { myChat->sendMessage(); }
void mainWindowImpl::setChatFocus() {
if(tabWidget->currentIndex() == 1) lineEdit_ChatInput->setFocus();
else lineEdit_ChatInput->clearFocus();
}
void mainWindowImpl::closeEvent(QCloseEvent *event) {
mySession->terminateNetworkClient();
+7 -1
View File
@@ -31,6 +31,7 @@
#include <QtCore>
class Log;
class Chat;
class ConfigFile;
class Session;
class Game;
@@ -66,7 +67,8 @@ public:
Session &getSession();
void setSession(boost::shared_ptr<Session> session);
void setLog(Log*);
void setLog(Log* l) { myLog = l; }
void setChat(Chat* c) { myChat = c; }
void setSpeeds();
@@ -234,6 +236,9 @@ public slots:
void paintStartSplash();
void sendChatMessage();
void setChatFocus();
void networkError(int, int);
void networkStart(boost::shared_ptr<Game> game);
@@ -244,6 +249,7 @@ private:
boost::shared_ptr<GuiInterface> myServerGuiInterface;
boost::shared_ptr<Session> mySession;
Log *myLog;
Chat *myChat;
ConfigFile *myConfig;
//Logo