add chat functions
This commit is contained in:
@@ -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())); }
|
||||
@@ -40,10 +40,9 @@ public:
|
||||
|
||||
public slots:
|
||||
|
||||
public:
|
||||
|
||||
signals:
|
||||
|
||||
void sendMessage();
|
||||
void receiveMessage(std::string);
|
||||
|
||||
private:
|
||||
|
||||
mainWindowImpl *myW;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user