This commit is contained in:
Max-Wilhelm Bruker 2009-08-23 16:53:51 +02:00
parent b51d4cd4f4
commit b113b78e7c
3 changed files with 20 additions and 4 deletions

View file

@ -2,8 +2,8 @@
#include "chatwidget.h"
#include "client.h"
ChannelWidget::ChannelWidget(Client *_client, const QString &_name, bool readOnly, QWidget *parent)
: QWidget(parent), client(_client), name(_name)
ChannelWidget::ChannelWidget(Client *_client, const QString &_name, bool readOnly, bool _virtualChannel, QWidget *parent)
: QWidget(parent), client(_client), name(_name), virtualChannel(_virtualChannel)
{
playerList = new QListWidget;
@ -27,6 +27,12 @@ ChannelWidget::ChannelWidget(Client *_client, const QString &_name, bool readOnl
setLayout(hbox);
}
ChannelWidget::~ChannelWidget()
{
if (!virtualChannel)
client->chatLeaveChannel(name);
}
void ChannelWidget::sendMessage()
{
if (sayEdit->text().isEmpty())
@ -111,6 +117,12 @@ void ChatWidget::enableChat()
void ChatWidget::disableChat()
{
disconnect(client, 0, this, 0);
while (tab->count()) {
ChannelWidget *cw = qobject_cast<ChannelWidget *>(tab->widget(0));
tab->removeTab(0);
delete cw;
}
channelList->clear();
hide();
}
@ -177,7 +189,7 @@ void ChatWidget::chatEvent(const ChatEventData &data)
if (msg[0].isEmpty()) {
w = getChannel("Server");
if (!w) {
w = new ChannelWidget(client, "Server", true);
w = new ChannelWidget(client, "Server", true, true);
tab->addTab(w, "Server");
}
} else

View file

@ -20,10 +20,12 @@ private:
QLineEdit *sayEdit;
Client *client;
QString name;
bool virtualChannel;
private slots:
void sendMessage();
public:
ChannelWidget(Client *_client, const QString &_name, bool readOnly = false, QWidget *parent = 0);
ChannelWidget(Client *_client, const QString &_name, bool readOnly = false, bool _virtualChannel = false, QWidget *parent = 0);
~ChannelWidget();
const QString &getName() const { return name; }
void joinEvent(const QString &playerName);

View file

@ -350,6 +350,8 @@ MainWindow::MainWindow(QTranslator *_translator, QWidget *parent)
void MainWindow::closeEvent(QCloseEvent */*event*/)
{
delete game;
chatWidget->disableChat();
gameSelector->disableGameList();
}
void MainWindow::changeEvent(QEvent *event)