lobbychat class added

This commit is contained in:
doitux
2007-09-07 20:26:13 +00:00
parent 78a2db39a1
commit 783536f6b7
7 changed files with 153 additions and 8 deletions
@@ -10,16 +10,19 @@
//
//
#include "gamelobbydialogimpl.h"
#include "lobbychat.h"
#include "session.h"
#include "configfile.h"
#include "gamedata.h"
#include <net/socket_msg.h>
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), isAdmin(false)
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), isAdmin(false), myChat(NULL)
{
setupUi(this);
myChat = new LobbyChat(this);
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
connect( treeWidget_GameList, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( gameSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
@@ -28,7 +31,8 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
connect( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) );
connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) );
connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), this, SLOT( checkChatInputLength(QString) ) );
clearDialog();
}
@@ -41,6 +45,9 @@ void gameLobbyDialogImpl::exec()
gameLobbyDialogImpl::~gameLobbyDialogImpl()
{
delete myChat;
myChat = NULL;
}
void gameLobbyDialogImpl::setSession(Session *session)
@@ -251,6 +258,7 @@ void gameLobbyDialogImpl::clearDialog()
treeWidget_GameList->setColumnWidth(1,75);
treeWidget_GameList->setColumnWidth(2,70);
pushButton_CreateGame->clearFocus();
lineEdit_ChatInput->setFocus();
}
@@ -375,4 +383,10 @@ void gameLobbyDialogImpl::kickPlayer() {
pushButton_Kick->setEnabled(false);
}
void gameLobbyDialogImpl::sendChatMessage() { /*myChat->sendMessage();*/ }
void gameLobbyDialogImpl::sendChatMessage() { myChat->sendMessage(); }
void gameLobbyDialogImpl::checkChatInputLength(QString string) { myChat->checkInputLength(string); }
void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) {
if (event->key() == Qt::Key_Enter) {}
}
@@ -26,6 +26,7 @@
class Session;
class ConfigFile;
class LobbyChat;
/**
@author FThauer FHammer <webmaster@pokerth.net>
@@ -40,6 +41,8 @@ public:
void exec();
void setSession(Session *session);
Session& getSession() { return *mySession; }
void setMyW ( mainWindowImpl* theValue ) { myW = theValue; }
public slots:
@@ -76,6 +79,9 @@ public slots:
void clearDialog();
void sendChatMessage();
void checkChatInputLength(QString string);
void keyPressEvent(QKeyEvent * event);
private:
@@ -83,6 +89,7 @@ private:
ConfigFile *myConfig;
Session *mySession;
createInternetGameDialogImpl *myCreateInternetGameDialog;
LobbyChat *myChat;
QString currentGameName;
bool isAdmin;
@@ -0,0 +1,66 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "lobbychat.h"
#include "gamelobbydialogimpl.h"
#include "session.h"
using namespace std;
LobbyChat::LobbyChat(gameLobbyDialogImpl* l) : myLobby(l)
{
connect(this, SIGNAL(signalChatMessage(QString, QString)), this, SLOT(receiveMessage(QString, QString)));
}
LobbyChat::~LobbyChat()
{
}
void LobbyChat::sendMessage() {
myLobby->getSession().sendChatMessage(myLobby->lineEdit_ChatInput->text().toUtf8().constData());
myLobby->lineEdit_ChatInput->setText("");
}
void LobbyChat::receiveMessage(QString playerName, QString message) {
myLobby->textBrowser_ChatDisplay->append(playerName + ": " + message);
}
void LobbyChat::checkInputLength(QString string) {
if(string.toUtf8().length() > 120) myLobby->lineEdit_ChatInput->setMaxLength(string.length());
}
void LobbyChat::clearChat() {
myLobby->textBrowser_ChatDisplay->clear();
/* QStringList wordList;
wordList << "alpha" << "omega" << "omicron" << "zeta";*/
// QCompleter *completer = new QCompleter(wordList, this);
// completer->setCaseSensitivity(Qt::CaseInsensitive);
// completer->setCompletionMode(QCompleter::InlineCompletion);
// // lineEdit_ChatInput->setCompleter(completer);
}
@@ -0,0 +1,54 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LOBBYCHAT_H
#define LOBBYCHAT_H
#include <string>
#include <QtCore>
class gameLobbyDialogImpl;
class Session;
class LobbyChat : public QObject
{
Q_OBJECT
public:
LobbyChat(gameLobbyDialogImpl*);
~LobbyChat();
signals:
void signalChatMessage(QString playerName, QString msg);
public slots:
void sendMessage();
void receiveMessage(QString playerName, QString msg);
void checkInputLength(QString);
void clearChat();
private:
gameLobbyDialogImpl *myLobby;
// friend class GuiWrapper;
};
#endif
+1 -1
View File
@@ -30,7 +30,7 @@ MyLeftTabWidget::MyLeftTabWidget(QGroupBox *parent)
int padding = 4;
#else
QString font1String("font-family: \"Nimbus Sans L\";");
int padding = 0;
int padding = -1;
#endif
QTabBar *myTabBar = this->tabBar();
+1 -1
View File
@@ -30,7 +30,7 @@ MyRightTabWidget::MyRightTabWidget(QGroupBox *parent)
int padding = 4;
#else
QString font1String("font-family: \"Nimbus Sans L\";");
int padding = 0;
int padding = -1;
#endif
QTabBar *myTabBar = this->tabBar();