chatRoom::chatRoom(int rId, QTcpSocket *socket, QTabWidget *tab, MainUser* mainUser, QMap<int, User*>* global) : ui(new Ui::ChatRoom) { ui->setupUi(this); this->tab = tab; this->roomID = rId; this->tabID = tab->count(); //asd //ChatRoomInterFace *inf = new ChatRoomInterFace; this->mainUser = mainUser; QString roomName = intToChar(rId); tab->addTab(this, "Private(" + roomName + ")"); this->display = ui->plainTextEdit; this->input = ui->textEdit; this->sendButton = ui->pushButton; this->sendFile = ui->pushButton_4; this->leaveRoom = ui->pushButton_3; this->add = ui->pushButton_2; this->userlist = ui->listWidget; this->socket = socket; this->uname = ui->lineEdit; this->sendButton->installEventFilter(this); this->input->installEventFilter(this); connect(sendButton, SIGNAL(clicked()), this, SLOT(sendText())); connect(leaveRoom, SIGNAL(clicked()), this, SLOT(leave())); connect(add, SIGNAL(clicked()), this, SLOT(inviteUser())); connect(sendFile, SIGNAL(clicked()), this, SLOT(sendFileSlot())); this->global = global; userNr = 0; //if() }
ChatWindow::ChatWindow(QString jid, QXmppClient *client, QWidget *parent) : QMainWindow(parent), m_jid(jid), m_client(client), m_selfState(QXmppMessage::Active), m_pausedTimer(new QTimer), m_inactiveTimer(new QTimer), m_goneTimer(new QTimer), m_statusBar(new QStatusBar), m_sendButton(new QPushButton), m_sendTip(new QLabel) { ui.setupUi(this); setWindowTitle(QString(tr("Contact: %1")).arg(m_jid)); m_editor = new MessageEdit(); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(m_editor); layout->setMargin(0); ui.editorWarpwidget->setLayout(layout); m_editor->setFocus(); m_sendButton->setText(tr("Send")); m_sendButton->setFixedHeight(m_statusBar->sizeHint().height()); m_statusBar->addPermanentWidget(m_sendTip); m_statusBar->addPermanentWidget(m_sendButton); m_statusBar->setSizeGripEnabled(false); setStatusBar(m_statusBar); // init ui QXmppRoster::QXmppRosterEntry entry = m_client->getRoster().getRosterEntry(jidToBareJid(m_jid)); ui.name->setText(entry.name()); ui.jid->setText(m_jid); if (m_client->getRoster().getResources(jidToBareJid(m_jid)).isEmpty()) ui.photo->setPixmap(QPixmap(":/images/user-identity-grey-100.png")); else ui.photo->setPixmap(QPixmap(":/images/user-identity-100.png")); connect(m_sendButton, SIGNAL(clicked()), this, SLOT(sendMessage())); connect(m_editor, SIGNAL(textChanged()), this, SLOT(sendComposing())); connect(m_pausedTimer, SIGNAL(timeout()), this, SLOT(pausedTimeout())); connect(m_inactiveTimer, SIGNAL(timeout()), this, SLOT(inactiveTimeout())); connect(m_goneTimer, SIGNAL(timeout()), this, SLOT(goneTimeout())); connect(ui.detailButton, SIGNAL(clicked()), this, SLOT(openContactInfoDialog()) ); // action connect(ui.actionSendFile, SIGNAL(triggered()), this, SLOT(sendFileSlot()) ); setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_DeleteOnClose, true); }