void ChatWindow::connecte() { ui->splitter->show(); Serveur *serveur = new Serveur; QTextEdit *textEdit = new QTextEdit; ui->hide3->hide(); ui->tab->addTab(textEdit, "Console/PM"); ui->tab->setTabToolTip(ui->tab->count() - 1, "irc.freenode.net"); // current tab is now the last, therefore remove all but the last for (int i = ui->tab->count(); i > 1; --i) { ui->tab->removeTab(0); } serveurs.insert("irc.freenode.net", serveur); serveur->pseudo = ui->editPseudo->text(); serveur->serveur = "irc.freenode.net"; serveur->port = 6667; serveur->affichage = textEdit; serveur->tab = ui->tab; serveur->userList = ui->userView; serveur->parent = this; textEdit->setReadOnly(true); connect(serveur, SIGNAL(joinTab()), this, SLOT(tabJoined())); connect(serveur, SIGNAL(tabJoined()), this, SLOT(tabJoining())); serveur->connectToHost("irc.freenode.net", 6667); ui->tab->setCurrentIndex(ui->tab->count() - 1); }
void IRCServer::messageTab(QString nick) { emit joinTab(); QTextEdit *textEdit = new QTextEdit; int index = tab->insertTab(tab->currentIndex() + 1, textEdit, nick); tab->setTabToolTip(index, "irc.freenode.net"); textEdit->setReadOnly(true); conversations.insert(nick, textEdit); emit tabJoined(); }
// Modified to stop blank and invalid nicks from passing void ChatWindow::connecte() { QRegExp validNick("([A-Za-z0-9_\\-\\\\\\[\\]{}^`|.]+)"); QString nick(ui->editNickname->text()); if (nick == "" || !validNick.exactMatch(nick)) { QPalette *palette = new QPalette(Qt::red); palette->setColor(QPalette::Text,Qt::red); ui->editNickname->setPalette(*palette); ui->editNickname->setFocus(); } else { ui->splitter->show(); IRCServer *ircserver = new IRCServer; QTextEdit *textEdit = new QTextEdit; ui->hide3->hide(); ui->tab->addTab(textEdit, "Console"); ui->tab->setTabToolTip(ui->tab->count() - 1, "irc.freenode.net"); // current tab is now the last, therefore remove all but the last for (int i = ui->tab->count(); i > 1; --i) { ui->tab->removeTab(0); } ircservers.insert("irc.freenode.net", ircserver); ircserver->nickname = ui->editNickname->text(); ircserver->ircserver = "irc.freenode.net"; ircserver->port = 6667; ircserver->display = textEdit; ircserver->tab = ui->tab; ircserver->userList = ui->userView; ircserver->parent = this; ircserver->userList->setEditTriggers(QAbstractItemView::NoEditTriggers); ircserver->userList->setSelectionMode(QAbstractItemView::NoSelection); textEdit->setReadOnly(true); connect(ircserver, SIGNAL(joinTab()), this, SLOT(tabJoined())); connect(ircserver, SIGNAL(tabJoined()), this, SLOT(tabJoining())); ircserver->connectToHost("irc.freenode.net", 6667); ui->tab->setCurrentIndex(ui->tab->count() - 1); } }
void IRCServer::join(QString chan) { emit joinTab(); QTextEdit *textEdit = new QTextEdit; int index = tab->insertTab(tab->currentIndex() + 2, textEdit, chan); tab->setTabToolTip(index, ircserver); tab->setCurrentIndex(index); textEdit->setReadOnly(true); conversations.insert(chan, textEdit); sendData("JOIN " + chan); emit tabJoined(); }
void Serveur::join(QString chan) { affichage->append("Joining " + chan + " channel"); emit joinTab(); QTextEdit *textEdit = new QTextEdit; int index = tab->insertTab(tab->currentIndex() + 1, textEdit, chan); tab->setTabToolTip(index, serveur); tab->setCurrentIndex(index); textEdit->setReadOnly(true); conversations.insert(chan, textEdit); sendData("JOIN " + chan); emit tabJoined(); }