From 0a21b29ffa7eca8b3fc10b504a726296a2e67abf Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Fri, 27 Dec 2013 06:07:29 +0000 Subject: [PATCH] minor bugs left --- JChatServerV2/bin/pad/prac2/Connection.class | Bin 3823 -> 0 bytes JChatServerV2/bin/pad/prac2/JChat$1.class | Bin 774 -> 0 bytes JChatServerV2/bin/pad/prac2/JChat.class | Bin 866 -> 0 bytes JChatServerV2/bin/pad/prac2/Server.class | Bin 6808 -> 0 bytes JChatServerV2/src/pad/prac2/Connection.java | 4 ++-- JChatServerV2/src/pad/prac2/JChat.java | 2 ++ JChatServerV2/src/pad/prac2/Server.java | 4 ++-- QChatClient/QChatClient.pro.user | 8 ++++---- QChatClient/Socket.cpp | 2 +- QChatClient/chatinputtext.cpp | 2 ++ QChatClient/chatroom.cpp | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------- QChatClient/chatroom.h | 57 +++++++++++++++++++++++++++++++++++---------------------- QChatClient/chatroom.ui | 20 +++++++++++++++++++- QChatClient/chatwidget.cpp | 31 +++++++++++++++++++++++++++---- QChatClient/chatwidget.h | 6 +++++- QChatClient/chatwindow.cpp | 43 +++++++++++++++++++++++++++++++++++++++---- QChatClient/chatwindow.h | 20 ++++++++++++++++++-- QChatClient/chatwindow.ui | 13 ++++++++++++- QChatClient/loginscreen.cpp | 12 ++++++------ QChatClient/loginscreen.h | 7 ++++--- build-QChatClient-Desktop-Debug/Makefile | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ build-QChatClient-Desktop-Debug/QChatClient | Bin 1863270 -> 0 bytes build-QChatClient-Desktop-Debug/Socket.o | Bin 87424 -> 0 bytes build-QChatClient-Desktop-Debug/chatwidget.o | Bin 246272 -> 0 bytes build-QChatClient-Desktop-Debug/chatwindow.o | Bin 548304 -> 0 bytes build-QChatClient-Desktop-Debug/loginscreen.o | Bin 546464 -> 0 bytes build-QChatClient-Desktop-Debug/main.o | Bin 239584 -> 0 bytes build-QChatClient-Desktop-Debug/moc_chatroom.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++------------------------------------------ build-QChatClient-Desktop-Debug/moc_chatroom.o | Bin 343648 -> 0 bytes build-QChatClient-Desktop-Debug/moc_chatwidget.cpp | 37 +++++++++++++++++++++++++++++-------- build-QChatClient-Desktop-Debug/moc_chatwidget.o | Bin 526768 -> 0 bytes build-QChatClient-Desktop-Debug/moc_chatwindow.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- build-QChatClient-Desktop-Debug/moc_chatwindow.o | Bin 243392 -> 0 bytes build-QChatClient-Desktop-Debug/moc_loginscreen.o | Bin 280960 -> 0 bytes build-QChatClient-Desktop-Debug/ui_chatroom.h | 12 +++++++++++- build-QChatClient-Desktop-Debug/ui_chatwindow.h | 9 ++++++++- 36 files changed, 577 insertions(+), 390 deletions(-) diff --git a/JChatServerV2/bin/pad/prac2/Connection.class b/JChatServerV2/bin/pad/prac2/Connection.class index 60fd918..45202b6 100644 Binary files a/JChatServerV2/bin/pad/prac2/Connection.class and b/JChatServerV2/bin/pad/prac2/Connection.class differ diff --git a/JChatServerV2/bin/pad/prac2/JChat$1.class b/JChatServerV2/bin/pad/prac2/JChat$1.class index b020840..d203d50 100644 Binary files a/JChatServerV2/bin/pad/prac2/JChat$1.class and b/JChatServerV2/bin/pad/prac2/JChat$1.class differ diff --git a/JChatServerV2/bin/pad/prac2/JChat.class b/JChatServerV2/bin/pad/prac2/JChat.class index 81345fb..3f22a28 100644 Binary files a/JChatServerV2/bin/pad/prac2/JChat.class and b/JChatServerV2/bin/pad/prac2/JChat.class differ diff --git a/JChatServerV2/bin/pad/prac2/Server.class b/JChatServerV2/bin/pad/prac2/Server.class index 62938a8..c7c1fe9 100644 Binary files a/JChatServerV2/bin/pad/prac2/Server.class and b/JChatServerV2/bin/pad/prac2/Server.class differ diff --git a/JChatServerV2/src/pad/prac2/Connection.java b/JChatServerV2/src/pad/prac2/Connection.java index fda5ab6..0a850bc 100644 --- a/JChatServerV2/src/pad/prac2/Connection.java +++ b/JChatServerV2/src/pad/prac2/Connection.java @@ -126,11 +126,11 @@ public class Connection extends Thread { if(!str.contains(" ")) { - serv.sendTo(this,str.substring(1),"1"); + serv.sendTo(this,str.substring(1),""); } else { - serv.sendTo(this,"1"+str.substring(1,str.indexOf(' ')),str.substring(str.indexOf(' ')+1)); + serv.sendTo(this,str.substring(1,str.indexOf(' ')),str.substring(str.indexOf(' ')+1)); } } catch(ChatException cE) diff --git a/JChatServerV2/src/pad/prac2/JChat.java b/JChatServerV2/src/pad/prac2/JChat.java index 907b3a4..02d7663 100644 --- a/JChatServerV2/src/pad/prac2/JChat.java +++ b/JChatServerV2/src/pad/prac2/JChat.java @@ -16,9 +16,11 @@ public class JChat System.out.print("Size of chatroom: "); roomSize = in.nextInt(); in.close();*/ + ip = "localhost"; port = 3001; roomSize = 5; + final Server serv = new Server(ip,port,roomSize); Runtime.getRuntime().addShutdownHook(new Thread() { diff --git a/JChatServerV2/src/pad/prac2/Server.java b/JChatServerV2/src/pad/prac2/Server.java index 2b34466..cc0b9a1 100644 --- a/JChatServerV2/src/pad/prac2/Server.java +++ b/JChatServerV2/src/pad/prac2/Server.java @@ -113,7 +113,7 @@ public class Server dest = it.next(); if(getNickname(dest).equals(nick)) { - dest.sendMessage(msg); + dest.sendMessage("1"+msg); lock.unlock(); return; } @@ -156,7 +156,7 @@ public class Server conn = it.next(); try { - conn.sendMessage("USERLIST:"+nickList()); + conn.sendMessage("USERLIST"+nickList()); } catch(IOException ioExc) { diff --git a/QChatClient/QChatClient.pro.user b/QChatClient/QChatClient.pro.user index 8e46c2c..1434025 100644 --- a/QChatClient/QChatClient.pro.user +++ b/QChatClient/QChatClient.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -51,9 +51,9 @@ ProjectExplorer.Project.Target.0 - Desktop - Desktop - {d6a12d1a-dee4-4341-8f4f-e2749eba145e} + Qt 5.0.1 (qt5) + Qt 5.0.1 (qt5) + {c01623e0-8a32-406c-bbaa-3e691c0f6afc} 0 0 0 diff --git a/QChatClient/Socket.cpp b/QChatClient/Socket.cpp index 440b407..4f9ce9c 100644 --- a/QChatClient/Socket.cpp +++ b/QChatClient/Socket.cpp @@ -186,4 +186,4 @@ const Socket& Socket::operator >> ( std::string& text ) message = NULL; } return *this; -} \ No newline at end of file +} diff --git a/QChatClient/chatinputtext.cpp b/QChatClient/chatinputtext.cpp index cd2efb2..f4129de 100644 --- a/QChatClient/chatinputtext.cpp +++ b/QChatClient/chatinputtext.cpp @@ -1,5 +1,7 @@ #include "chatinputtext.h" +#include + chatInputText::chatInputText(QWidget *parent) : QTextEdit(parent) { diff --git a/QChatClient/chatroom.cpp b/QChatClient/chatroom.cpp index 445f21a..9a9b4b6 100644 --- a/QChatClient/chatroom.cpp +++ b/QChatClient/chatroom.cpp @@ -2,41 +2,12 @@ #include "ui_chatroom.h" list sendQueue; - std::mutex myMutex; - std::mutex msgMutex; +std::mutex printMutex; unique_lock* msgLock; - std::condition_variable msgListNotEmpty; -Chatroom::Chatroom(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::Chatroom) -{ - ui->setupUi(this); - QList chatSizes; - QList splitSizes; - chatSizes.push_front(ui->chatText->height()); - chatSizes.push_front(100); - splitSizes.push_front(ui->chatWindow->width()); - splitSizes.push_front(200); - ui->chatSplitter->setSizes(chatSizes); - ui->windowSplitter->setSizes(splitSizes); - connected = false; - msgLock = new unique_lock(msgMutex,std::defer_lock); - send = NULL; - recv = NULL; - - connect(ui->actionConnect,SIGNAL(triggered()),this,SLOT(startSession())); - connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(finish())); - connect(this,SIGNAL(threadsFinished(bool)),this,SLOT(finishThreads(bool))); - connect(ui->inputText,SIGNAL(msgReady()),this,SLOT(sendMsg())); - connect(ui->actionDisconnect,SIGNAL(triggered()),this,SLOT(disconnectChatroom())); - connect(ui->sendButton,SIGNAL(clicked()),this,SLOT(sendMsg())); - connect(this,SIGNAL(messagesToPrint()),this,SLOT(printMsg())); -} - void sendThread(Socket* s, Chatroom* chat) { string send; @@ -46,11 +17,11 @@ void sendThread(Socket* s, Chatroom* chat) { msgLock->lock(); msgListNotEmpty.wait(*msgLock); + msgLock->unlock(); if(!chat->getConnected()) { return; } - msgLock->unlock(); } msgLock->lock(); send = sendQueue.front().toStdString(); @@ -59,27 +30,31 @@ void sendThread(Socket* s, Chatroom* chat) { if(send[0] == '@') { + chat->relayMsg(send); send = '1' + send; } else { send = '0' + send; + if(send.substr(1) != "/exit" && send.substr(1) != "/disconnect") + { + chat->putMsgToPrintQueue(chat->getNickname().toStdString().append(": ").append(send.substr(1))); + } } - *s << send; msgLock->unlock(); + *s << send; send = send.substr(1); if(send == "/disconnect" || send == "/exit") { break; } - chat->putMsgToPrintQueue(chat->getNickname().toStdString().append(": ").append(send)); + } catch(SocketException& e) { cout << e.description() << endl; } } - cout << "sendThread finished" << endl; } void recvThread(Socket* s, Chatroom* chat) @@ -92,8 +67,7 @@ void recvThread(Socket* s, Chatroom* chat) *s >> recv; if(recv[0] == '1') { - recv = recv.substr(1); - chat->relayMsg(recv); + chat->relayMsg(recv.substr(1)); continue; } else if(recv[0] == '0') @@ -106,7 +80,7 @@ void recvThread(Socket* s, Chatroom* chat) chat->setConnected(false); cout << e.description() << endl; msgListNotEmpty.notify_all(); - emit chat->threadsFinished(false); + chat->close(); break; } if(recv == "DISC_OK") @@ -114,7 +88,6 @@ void recvThread(Socket* s, Chatroom* chat) cout << "Disconnecting" << endl; chat->setConnected(false); msgListNotEmpty.notify_all(); - emit chat->threadsFinished(false); break; } else if(recv == "EXIT_OK") @@ -122,15 +95,71 @@ void recvThread(Socket* s, Chatroom* chat) cout << "Exiting" << endl; chat->setConnected(false); msgListNotEmpty.notify_all(); - emit chat->threadsFinished(true); + chat->close(); break; } + else if(recv.substr(0,8) == "USERLIST") + { + QString userlist = QString::fromStdString(recv.substr(8)); + chat->updateUserList(userlist); + } else { chat->putMsgToPrintQueue(recv); } } - cout << "recvThread finished" << endl; +} + +Chatroom::Chatroom(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::Chatroom) +{ + ui->setupUi(this); + QList chatSizes; + QList splitSizes; + chatSizes.push_front(ui->chatText->height()); + chatSizes.push_front(100); + splitSizes.push_front(ui->chatWindow->width()); + splitSizes.push_front(200); + ui->chatSplitter->setSizes(chatSizes); + ui->windowSplitter->setSizes(splitSizes); + + connected = false; + msgLock = new unique_lock(msgMutex,std::defer_lock); + chatLock = new unique_lock(chatMutex,std::defer_lock); + send = NULL; + recv = NULL; + + connect(ui->actionConnect,SIGNAL(triggered()),this,SLOT(startSession())); + connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close())); + connect(ui->actionDisconnect,SIGNAL(triggered()),this,SLOT(disconnectChatroom())); + connect(ui->actionSave_chat,SIGNAL(triggered()),ui->chatText,SLOT(saveChatToFile())); + connect(ui->inputText,SIGNAL(msgReady()),this,SLOT(sendMsg())); + connect(ui->sendButton,SIGNAL(clicked()),this,SLOT(sendMsg())); + connect(this,SIGNAL(messagesToPrint()),this,SLOT(printMsg())); + connect(ui->userList,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(launchChatWindow(QModelIndex))); + connect(this,SIGNAL(createChat(QString)),this,SLOT(newChat(QString))); +} + +void Chatroom::closeEvent(QCloseEvent *event) +{ + if(recv == NULL && send == NULL) + { + ui->inputText->setReadOnly(true); + ui->chatText->printServerMsg("Disconnected"); + event->accept(); + return; + } + sendQueue.clear(); + QString exitMsg("/exit"); + putMsgToSendQueue(exitMsg); + ui->inputText->setReadOnly(true); + recv->join(); + send->join(); + ui->chatText->printServerMsg("Disconnected"); + send = NULL; + recv = NULL; + event->accept(); } bool Chatroom::getConnected() @@ -148,27 +177,72 @@ void Chatroom::setConnected(bool status) myMutex.unlock(); } -void Chatroom::putMsgToPrintQueue(string &msg) +void Chatroom::setNickname(QString nick) { - printQueue.push_back(msg); - emit messagesToPrint(); + nickname = nick; } -string Chatroom::getSender(string& msg) +QString Chatroom::getNickname() { - return msg.substr(5,msg.find(':')-5); + return nickname; } -void Chatroom::relayMsg(string& msg) +void Chatroom::updateUserList(QString userlist) { - string sender = getSender(msg); - map::iterator it = activeChats.begin(); - if(activeChats.find(sender) == activeChats.end()) + ui->userList->clear(); + QStringList users = userlist.split('\n',QString::SkipEmptyParts); + for(int i = 0; i < users.size(); i++) { - //LAUNCH new windowchat + ui->userList->addItem(users[i]); } +} + +void Chatroom::relayMsg(string msg) +{ + string sender = getSender(msg); + //AT LEAST SOME FUCKING SANITY CHECK... PLEASE!!! + map::iterator it = activeChats.begin(); it = activeChats.find(sender); - it->second.printMsg(msg); + if(it == activeChats.end()) + { + chatLock->lock(); + emit createChat(QString::fromStdString(sender)); + chatCreated.wait(*chatLock); + chatLock->unlock(); + it = activeChats.find(sender); + } + ((ChatWindow*)it->second)->notifyPrint(msg); //NOT GOOD! +} + +void Chatroom::newChat(QString peerNick) +{ + ChatWindow* newchat = new ChatWindow(peerNick,this); + activeChats.insert(std::pair(peerNick.toStdString(),newchat)); + newchat->show(); + chatCreated.notify_all(); +} + +void Chatroom::removeChat(QString &nickname) +{ + ChatWindow* chat = (ChatWindow*)activeChats.find(nickname.toStdString())->second; + delete chat; + activeChats.erase(nickname.toStdString()); +} + +void Chatroom::launchChatWindow(QModelIndex index) +{ + QString peerNick = ui->userList->model()->data(index).toString(); + if(activeChats.find(peerNick.toStdString()) == activeChats.end()) + { + emit newChat(peerNick); + } +} + +void Chatroom::putMsgToPrintQueue(string &msg) +{ + printMutex.lock(); + printQueue.push_back(msg); + emit messagesToPrint(); } void Chatroom::printMsg() @@ -179,6 +253,7 @@ void Chatroom::printMsg() ui->chatText->printMsg(msg); printQueue.pop_front(); } + printMutex.unlock(); } void Chatroom::putMsgToSendQueue(QString& msg) @@ -189,55 +264,35 @@ void Chatroom::putMsgToSendQueue(QString& msg) msgListNotEmpty.notify_all(); } -void Chatroom::setNickname(QString nick) -{ - nickname = nick; -} - -QString Chatroom::getNickname() -{ - return nickname; -} - -void Chatroom::startSession() +void Chatroom::sendMsg() { - LoginScreen login(&s,this); - login.exec(); - int result = login.result(); - if(result == QDialog::Accepted) + QString msg = ui->inputText->toPlainText(); + ui->inputText->clear(); + if(msg == "/disconnect") { - ui->inputText->setReadOnly(false); + this->disconnectChatroom(); } - else if(result == QDialog::Rejected) + else if(msg == "/exit") { - return; + this->close(); + } + else + { + putMsgToSendQueue(msg); } - connected = true; - ui->chatText->printServerMsg("Connected to chatroom"); - recv = new std::thread(recvThread,&s,this); - send = new std::thread(sendThread,&s,this); -} - -void Chatroom::sendMsg() -{ - QString msg = ui->inputText->toPlainText(); - ui->inputText->clear(); - putMsgToSendQueue(msg); } -void Chatroom::finish() +string Chatroom::getSender(string msg) { - if(recv == NULL && send == NULL) + cout << msg << endl; + if(msg[0] == '@') { - ui->inputText->setReadOnly(true); - ui->chatText->printServerMsg("Disconnected"); - this->close(); + return msg.substr(1,msg.find(" ")-1); + } + else + { + return msg.substr(0,msg.find(":")); } - msgMutex.lock(); - sendQueue.clear(); - sendQueue.push_back("/exit"); - msgMutex.unlock(); - msgListNotEmpty.notify_all(); } void Chatroom::disconnectChatroom() @@ -245,24 +300,34 @@ void Chatroom::disconnectChatroom() msgMutex.lock(); sendQueue.clear(); sendQueue.push_back("/disconnect"); + ui->chatText->printServerMsg("Disconnected"); + this->ui->inputText->setReadOnly(true); + this->ui->sendButton->setDisabled(true); + this->ui->actionDisconnect->setDisabled(true); msgMutex.unlock(); msgListNotEmpty.notify_all(); } -void Chatroom::finishThreads(bool exit) +void Chatroom::startSession() { - myMutex.lock(); - ui->inputText->setReadOnly(true); - recv->join(); - send->join(); - myMutex.unlock(); - ui->chatText->printServerMsg("Disconnected"); - send = NULL; - recv = NULL; - if(exit) + LoginScreen login(&s,this); + login.exec(); + int result = login.result(); + if(result == QDialog::Accepted) { - this->close(); + ui->inputText->setReadOnly(false); + } + else if(result == QDialog::Rejected) + { + return; } + connected = true; + this->ui->inputText->setReadOnly(false); + this->ui->sendButton->setDisabled(false); + this->ui->actionDisconnect->setDisabled(false); + ui->chatText->printServerMsg("Connected to chatroom"); + recv = new std::thread(recvThread,&s,this); + send = new std::thread(sendThread,&s,this); } Chatroom::~Chatroom() @@ -270,6 +335,12 @@ Chatroom::~Chatroom() delete msgLock; delete recv; delete send; + map::iterator it; + for(it = activeChats.begin(); it != activeChats.end(); it++) + { + ChatWindow* chat = (ChatWindow*) it->second; + delete chat; + } delete ui; } diff --git a/QChatClient/chatroom.h b/QChatClient/chatroom.h index e7080d6..6d4eeca 100644 --- a/QChatClient/chatroom.h +++ b/QChatClient/chatroom.h @@ -2,13 +2,14 @@ #define CHATROOM_H #include -#include "Socket.h" -#include "loginscreen.h" +#include #include #include #include -#include "chatwindow.h" #include +#include "loginscreen.h" +#include "chatwindow.h" +#include "Socket.h" namespace Ui { class Chatroom; @@ -22,37 +23,49 @@ public: explicit Chatroom(QWidget *parent = 0); bool getConnected(); void setConnected(bool status); - void relayMsg(string& msg); - void setNickname(QString nick); QString getNickname(); + void setNickname(QString nick); + void updateUserList(QString userlist); + void relayMsg(string msg); + void removeChat(QString &nickname); void putMsgToPrintQueue(string& msg); + void putMsgToSendQueue(QString& msg); ~Chatroom(); +private: + Ui::Chatroom *ui; + Socket s; + bool connected; + std::thread *send; + std::thread *recv; + QString nickname; + list printQueue; + map activeChats; + std::mutex chatMutex; + unique_lock* chatLock; + std::condition_variable chatCreated; + string getSender(string msg); + +private slots: + void newChat(QString peerNick); + + +protected: + void closeEvent(QCloseEvent *event); + public slots: void startSession(); void sendMsg(); - void printMsg(); + void disconnectChatroom(); + void launchChatWindow(QModelIndex index); private slots: - void finishThreads(bool exit); - void finish(); - void disconnectChatroom(); + void printMsg(); signals: - void threadsFinished(bool exit); void messagesToPrint(); - -private: - Ui::Chatroom *ui; - map activeChats; - bool connected; - string getSender(string& msg); - void putMsgToSendQueue(QString& msg); - std::thread *send; - std::thread *recv; - Socket s; - QString nickname; - list printQueue; + void createChat(QString sender); + }; void sendThread(Socket* s, Chatroom *chat); diff --git a/QChatClient/chatroom.ui b/QChatClient/chatroom.ui index aa7a479..0905cd5 100644 --- a/QChatClient/chatroom.ui +++ b/QChatClient/chatroom.ui @@ -44,7 +44,7 @@ - false + true @@ -92,6 +92,9 @@ + + false + 0 @@ -120,6 +123,7 @@ + @@ -135,10 +139,18 @@ + + false + Disconnect + + + Save chat... + + @@ -152,6 +164,12 @@
chatinputtext.h
+ + chatText + inputText + userList + sendButton + diff --git a/QChatClient/chatwidget.cpp b/QChatClient/chatwidget.cpp index 9b2c7f4..69f1809 100644 --- a/QChatClient/chatwidget.cpp +++ b/QChatClient/chatwidget.cpp @@ -6,17 +6,40 @@ ChatWidget::ChatWidget(QWidget *parent) : } -void ChatWidget::printServerMsg(const string &str) +void ChatWidget::printMsg(const string &str) { - this->append("

" + QString::fromStdString(str) + "

"); + this->setFontWeight(QFont::Normal); + this->setFontItalic(false); + this->setTextColor(Qt::black); + this->append(QString::fromStdString(str)); } -void ChatWidget::printMsg(const string &str) +void ChatWidget::printServerMsg(const string &str) { + this->setFontWeight(QFont::Normal); + this->setFontItalic(true); + this->setTextColor(Qt::gray); this->append(QString::fromStdString(str)); } void ChatWidget::printStatusMsg(const string &str) { - this->append("

" + QString::fromStdString(str) + "

"); + this->setFontWeight(QFont::Bold); + this->setFontItalic(false); + this->setTextColor(Qt::black); + this->append(QString::fromStdString(str)); +} + +void ChatWidget::saveChatToFile() +{ + QFileDialog fileDialog; + fileDialog.setFileMode(QFileDialog::AnyFile); + fileDialog.setAcceptMode(QFileDialog::AcceptSave); + fileDialog.exec(); + QString filename = fileDialog.selectedFiles().front(); + QFile file(filename); + file.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream fileOut(&file); + fileOut << this->toPlainText() << endl; + file.close(); } diff --git a/QChatClient/chatwidget.h b/QChatClient/chatwidget.h index eb7610d..440eea3 100644 --- a/QChatClient/chatwidget.h +++ b/QChatClient/chatwidget.h @@ -2,6 +2,9 @@ #define CHATWIDGET_H #include +#include +#include +#include using namespace std; @@ -10,13 +13,14 @@ class ChatWidget : public QTextEdit Q_OBJECT public: explicit ChatWidget(QWidget *parent = 0); - void printServerMsg(const string &str); void printMsg(const string& str); + void printServerMsg(const string &str); void printStatusMsg(const string& str); signals: public slots: + void saveChatToFile(); }; diff --git a/QChatClient/chatwindow.cpp b/QChatClient/chatwindow.cpp index 5477699..ccf25bf 100644 --- a/QChatClient/chatwindow.cpp +++ b/QChatClient/chatwindow.cpp @@ -3,7 +3,7 @@ using namespace std; -ChatWindow::ChatWindow(QString& nickname, QWidget *parent) : +ChatWindow::ChatWindow(QString nick, QWidget *parent) : QMainWindow(parent), ui(new Ui::ChatWindow) { @@ -12,13 +12,48 @@ ChatWindow::ChatWindow(QString& nickname, QWidget *parent) : sizes.push_front(ui->chatText->height()); sizes.push_front(100); ui->splitter->setSizes(sizes); - this->setWindowTitle("Chat with " + nickname); + + nickName = nick; + myNickname = ((Chatroom*)this->parent())->getNickname(); + this->setWindowTitle("Chat with " + nick); + connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close())); + connect(ui->actionSave_chat,SIGNAL(triggered()),ui->chatText,SLOT(saveChatToFile())); + connect(ui->inputText,SIGNAL(msgReady()),this,SLOT(sendMsg())); + connect(ui->sendButton,SIGNAL(clicked()),this,SLOT(sendMsg())); + connect(this,SIGNAL(msgToPrint(QString)),this,SLOT(printMsg(QString))); +} + +void ChatWindow::notifyPrint(string &msg) +{ + emit msgToPrint(QString::fromStdString(msg)); +} + +void ChatWindow::printMsg(QString str) +{ + string msg = str.toStdString(); + if(str[0] == '@') + { + ui->chatText->printMsg(myNickname.toStdString() + ":" + msg.substr(msg.find(" "))); + } + else + { + ui->chatText->printMsg(msg); + } +} + +void ChatWindow::sendMsg() +{ + QString msg = ui->inputText->toPlainText(); + ui->inputText->clear(); + msg = "@" + nickName + " " +msg; + ((Chatroom*)this->parent())->putMsgToSendQueue(msg); } -void ChatWindow::printMsg(string& str) +void ChatWindow::closeEvent(QCloseEvent *event) { - ui->chatText->printMsg(str); + ((Chatroom*)this->parent())->removeChat(this->nickName); + event->accept(); } ChatWindow::~ChatWindow() diff --git a/QChatClient/chatwindow.h b/QChatClient/chatwindow.h index 027602b..9c2f1e7 100644 --- a/QChatClient/chatwindow.h +++ b/QChatClient/chatwindow.h @@ -3,6 +3,7 @@ #include #include +#include "chatroom.h" using namespace std; @@ -15,12 +16,27 @@ class ChatWindow : public QMainWindow Q_OBJECT public: - explicit ChatWindow(QString& nickname,QWidget *parent = 0); - void printMsg(string& str); + explicit ChatWindow(QString nick, QWidget *parent = 0); + void notifyPrint(string& msg); ~ChatWindow(); + +public slots: + void sendMsg(); private: Ui::ChatWindow *ui; + QString nickName; + QString myNickname; + +private slots: + void printMsg(QString str); + +protected: + void closeEvent(QCloseEvent *event); + +signals: + void msgToPrint(QString msg); + }; #endif // CHATWINDOW_H diff --git a/QChatClient/chatwindow.ui b/QChatClient/chatwindow.ui index 9d9b960..9bea8d0 100644 --- a/QChatClient/chatwindow.ui +++ b/QChatClient/chatwindow.ui @@ -92,7 +92,7 @@ - true + false @@ -115,6 +115,7 @@ Chat + @@ -124,6 +125,11 @@ Exit + + + Save chat... + + @@ -138,6 +144,11 @@
chatinputtext.h
+ + chatText + inputText + sendButton + diff --git a/QChatClient/loginscreen.cpp b/QChatClient/loginscreen.cpp index 17f9317..f3bc36a 100644 --- a/QChatClient/loginscreen.cpp +++ b/QChatClient/loginscreen.cpp @@ -15,6 +15,12 @@ LoginScreen::LoginScreen(Socket* s, QWidget *parent) : connect(ui->cancelButton,SIGNAL(clicked()),this,SLOT(cancelLogin())); } +bool LoginScreen::validateURL(QString& URL) +{ + QRegExp regex("([a-zA-Z.]+|((\\d{1,3}\\.){3}\\d{1,3})):\\d+"); + return regex.exactMatch(URL); +} + bool LoginScreen::parseURL(QString& URL) { if(validateURL(URL)) @@ -32,12 +38,6 @@ bool LoginScreen::parseURL(QString& URL) } } -bool LoginScreen::validateURL(QString& URL) -{ - QRegExp regex("([a-zA-Z.]+|((\\d{1,3}\\.){3}\\d{1,3})):\\d+"); - return regex.exactMatch(URL); -} - void LoginScreen::connectToChat() { QString nick; diff --git a/QChatClient/loginscreen.h b/QChatClient/loginscreen.h index 95f8292..e73609c 100644 --- a/QChatClient/loginscreen.h +++ b/QChatClient/loginscreen.h @@ -3,8 +3,9 @@ #include #include -#include "Socket.h" #include "chatroom.h" +#include "Socket.h" + namespace Ui { class LoginScreen; @@ -26,9 +27,9 @@ public slots: private: Ui::LoginScreen *ui; - int port; - QString host; Socket* s; + QString host; + int port; }; #endif // LOGINSCREEN_H diff --git a/build-QChatClient-Desktop-Debug/Makefile b/build-QChatClient-Desktop-Debug/Makefile index d9bf3c1..71a491f 100644 --- a/build-QChatClient-Desktop-Debug/Makefile +++ b/build-QChatClient-Desktop-Debug/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: QChatClient -# Generated by qmake (3.0) (Qt 5.0.2) on: mié dic 25 23:23:03 2013 +# Generated by qmake (3.0) (Qt 5.0.2) on: vie dic 27 07:18:49 2013 # Project: ../QChatClient/QChatClient.pro # Template: app # Command: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake -spec linux-g++-64 CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ../QChatClient/QChatClient.pro @@ -414,14 +414,16 @@ moc_loginscreen.cpp: /usr/include/qt5/QtWidgets/QDialog \ /usr/include/qt5/QtGui/qvector2d.h \ /usr/include/qt5/QtGui/qtouchdevice.h \ /usr/include/qt5/QtCore/QRegExp \ - ../QChatClient/Socket.h \ - ../QChatClient/SocketException.h \ ../QChatClient/chatroom.h \ /usr/include/qt5/QtWidgets/QMainWindow \ /usr/include/qt5/QtWidgets/qmainwindow.h \ /usr/include/qt5/QtWidgets/qtabwidget.h \ /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtCore/QModelIndex \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ ../QChatClient/loginscreen.h \ + ../QChatClient/Socket.h \ + ../QChatClient/SocketException.h \ ../QChatClient/chatwindow.h \ ../QChatClient/loginscreen.h /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) ../QChatClient/loginscreen.h -o moc_loginscreen.cpp @@ -536,14 +538,16 @@ moc_chatroom.cpp: /usr/include/qt5/QtWidgets/QMainWindow \ /usr/include/qt5/QtGui/qtouchdevice.h \ /usr/include/qt5/QtWidgets/qtabwidget.h \ /usr/include/qt5/QtGui/qicon.h \ - ../QChatClient/Socket.h \ - ../QChatClient/SocketException.h \ + /usr/include/qt5/QtCore/QModelIndex \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ ../QChatClient/loginscreen.h \ /usr/include/qt5/QtWidgets/QDialog \ /usr/include/qt5/QtWidgets/qdialog.h \ /usr/include/qt5/QtCore/QRegExp \ ../QChatClient/chatroom.h \ ../QChatClient/chatwindow.h \ + ../QChatClient/Socket.h \ + ../QChatClient/SocketException.h \ ../QChatClient/chatroom.h /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) ../QChatClient/chatroom.h -o moc_chatroom.cpp @@ -662,6 +666,13 @@ moc_chatwidget.cpp: /usr/include/qt5/QtWidgets/QTextEdit \ /usr/include/qt5/QtGui/qtextcursor.h \ /usr/include/qt5/QtGui/qtextformat.h \ /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtWidgets/QFileDialog \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QFile \ + /usr/include/qt5/QtCore/QTextStream \ ../QChatClient/chatwidget.h /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) ../QChatClient/chatwidget.h -o moc_chatwidget.cpp @@ -775,6 +786,16 @@ moc_chatwindow.cpp: /usr/include/qt5/QtWidgets/QMainWindow \ /usr/include/qt5/QtGui/qtouchdevice.h \ /usr/include/qt5/QtWidgets/qtabwidget.h \ /usr/include/qt5/QtGui/qicon.h \ + ../QChatClient/chatroom.h \ + /usr/include/qt5/QtCore/QModelIndex \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ + ../QChatClient/loginscreen.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QRegExp \ + ../QChatClient/Socket.h \ + ../QChatClient/SocketException.h \ + ../QChatClient/chatwindow.h \ ../QChatClient/chatwindow.h /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) ../QChatClient/chatwindow.h -o moc_chatwindow.cpp @@ -1022,6 +1043,13 @@ ui_chatwindow.h: ../QChatClient/chatwindow.ui \ /usr/include/qt5/QtGui/qtextcursor.h \ /usr/include/qt5/QtGui/qtextformat.h \ /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtWidgets/QFileDialog \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QFile \ + /usr/include/qt5/QtCore/QTextStream \ /usr/include/qt5/QtWidgets/QTextEdit \ /usr/include/qt5/QtWidgets/qtextedit.h \ /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ @@ -1261,6 +1289,13 @@ ui_chatroom.h: ../QChatClient/chatroom.ui \ /usr/include/qt5/QtGui/qtextcursor.h \ /usr/include/qt5/QtGui/qtextformat.h \ /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtWidgets/QFileDialog \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QFile \ + /usr/include/qt5/QtCore/QTextStream \ /usr/include/qt5/QtWidgets/QTextEdit \ /usr/include/qt5/QtWidgets/qtextedit.h \ /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ @@ -1499,14 +1534,16 @@ main.o: ../QChatClient/main.cpp ../QChatClient/loginscreen.h \ /usr/include/qt5/QtGui/qvector2d.h \ /usr/include/qt5/QtGui/qtouchdevice.h \ /usr/include/qt5/QtCore/QRegExp \ - ../QChatClient/Socket.h \ - ../QChatClient/SocketException.h \ ../QChatClient/chatroom.h \ /usr/include/qt5/QtWidgets/QMainWindow \ /usr/include/qt5/QtWidgets/qmainwindow.h \ /usr/include/qt5/QtWidgets/qtabwidget.h \ /usr/include/qt5/QtGui/qicon.h \ + /usr/include/qt5/QtCore/QModelIndex \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ ../QChatClient/chatwindow.h \ + ../QChatClient/Socket.h \ + ../QChatClient/SocketException.h \ /usr/include/qt5/QtWidgets/QApplication \ /usr/include/qt5/QtWidgets/qapplication.h \ /usr/include/qt5/QtCore/qcoreapplication.h \ @@ -1626,62 +1663,17 @@ loginscreen.o: ../QChatClient/loginscreen.cpp ../QChatClient/loginscreen.h \ /usr/include/qt5/QtGui/qvector2d.h \ /usr/include/qt5/QtGui/qtouchdevice.h \ /usr/include/qt5/QtCore/QRegExp \ - ../QChatClient/Socket.h \ - ../QChatClient/SocketException.h \ ../QChatClient/chatroom.h \ /usr/include/qt5/QtWidgets/QMainWindow \ /usr/include/qt5/QtWidgets/qmainwindow.h \ /usr/include/qt5/QtWidgets/qtabwidget.h \ /usr/include/qt5/QtGui/qicon.h \ - ../QChatClient/chatwindow.h \ - ui_loginscreen.h \ - /usr/include/qt5/QtCore/QVariant \ - /usr/include/qt5/QtWidgets/QAction \ - /usr/include/qt5/QtWidgets/qaction.h \ - /usr/include/qt5/QtWidgets/qactiongroup.h \ - /usr/include/qt5/QtWidgets/QApplication \ - /usr/include/qt5/QtWidgets/qapplication.h \ - /usr/include/qt5/QtCore/qcoreapplication.h \ - /usr/include/qt5/QtCore/qeventloop.h \ - /usr/include/qt5/QtWidgets/qdesktopwidget.h \ - /usr/include/qt5/QtGui/qguiapplication.h \ - /usr/include/qt5/QtGui/qinputmethod.h \ - /usr/include/qt5/QtWidgets/QButtonGroup \ - /usr/include/qt5/QtWidgets/qbuttongroup.h \ - /usr/include/qt5/QtWidgets/QGridLayout \ - /usr/include/qt5/QtWidgets/qgridlayout.h \ - /usr/include/qt5/QtWidgets/qlayout.h \ - /usr/include/qt5/QtWidgets/qlayoutitem.h \ - /usr/include/qt5/QtWidgets/qboxlayout.h \ - /usr/include/qt5/QtWidgets/QHeaderView \ - /usr/include/qt5/QtWidgets/qheaderview.h \ - /usr/include/qt5/QtWidgets/qabstractitemview.h \ - /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ - /usr/include/qt5/QtWidgets/qframe.h \ + /usr/include/qt5/QtCore/QModelIndex \ /usr/include/qt5/QtCore/qabstractitemmodel.h \ - /usr/include/qt5/QtCore/qitemselectionmodel.h \ - /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ - /usr/include/qt5/QtWidgets/qstyleoption.h \ - /usr/include/qt5/QtWidgets/qabstractspinbox.h \ - /usr/include/qt5/QtGui/qvalidator.h \ - /usr/include/qt5/QtWidgets/qslider.h \ - /usr/include/qt5/QtWidgets/qabstractslider.h \ - /usr/include/qt5/QtWidgets/qstyle.h \ - /usr/include/qt5/QtWidgets/qtabbar.h \ - /usr/include/qt5/QtWidgets/qrubberband.h \ - /usr/include/qt5/QtWidgets/QLabel \ - /usr/include/qt5/QtWidgets/qlabel.h \ - /usr/include/qt5/QtWidgets/QLineEdit \ - /usr/include/qt5/QtWidgets/qlineedit.h \ - /usr/include/qt5/QtGui/qtextcursor.h \ - /usr/include/qt5/QtGui/qtextformat.h \ - /usr/include/qt5/QtGui/qpen.h \ - /usr/include/qt5/QtGui/qtextoption.h \ - /usr/include/qt5/QtWidgets/QPushButton \ - /usr/include/qt5/QtWidgets/qpushbutton.h \ - /usr/include/qt5/QtWidgets/qabstractbutton.h \ - /usr/include/qt5/QtWidgets/QSpacerItem \ - /usr/include/qt5/QtWidgets/QWidget + ../QChatClient/chatwindow.h \ + ../QChatClient/Socket.h \ + ../QChatClient/SocketException.h \ + ui_loginscreen.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o loginscreen.o ../QChatClient/loginscreen.cpp chatroom.o: ../QChatClient/chatroom.cpp ../QChatClient/chatroom.h \ @@ -1795,71 +1787,16 @@ chatroom.o: ../QChatClient/chatroom.cpp ../QChatClient/chatroom.h \ /usr/include/qt5/QtGui/qtouchdevice.h \ /usr/include/qt5/QtWidgets/qtabwidget.h \ /usr/include/qt5/QtGui/qicon.h \ - ../QChatClient/Socket.h \ - ../QChatClient/SocketException.h \ + /usr/include/qt5/QtCore/QModelIndex \ + /usr/include/qt5/QtCore/qabstractitemmodel.h \ ../QChatClient/loginscreen.h \ /usr/include/qt5/QtWidgets/QDialog \ /usr/include/qt5/QtWidgets/qdialog.h \ /usr/include/qt5/QtCore/QRegExp \ + ../QChatClient/Socket.h \ + ../QChatClient/SocketException.h \ ../QChatClient/chatwindow.h \ - ui_chatroom.h \ - /usr/include/qt5/QtCore/QVariant \ - /usr/include/qt5/QtWidgets/QAction \ - /usr/include/qt5/QtWidgets/qaction.h \ - /usr/include/qt5/QtWidgets/qactiongroup.h \ - /usr/include/qt5/QtWidgets/QApplication \ - /usr/include/qt5/QtWidgets/qapplication.h \ - /usr/include/qt5/QtCore/qcoreapplication.h \ - /usr/include/qt5/QtCore/qeventloop.h \ - /usr/include/qt5/QtWidgets/qdesktopwidget.h \ - /usr/include/qt5/QtGui/qguiapplication.h \ - /usr/include/qt5/QtGui/qinputmethod.h \ - /usr/include/qt5/QtWidgets/QButtonGroup \ - /usr/include/qt5/QtWidgets/qbuttongroup.h \ - /usr/include/qt5/QtWidgets/QGridLayout \ - /usr/include/qt5/QtWidgets/qgridlayout.h \ - /usr/include/qt5/QtWidgets/qlayout.h \ - /usr/include/qt5/QtWidgets/qlayoutitem.h \ - /usr/include/qt5/QtWidgets/qboxlayout.h \ - /usr/include/qt5/QtWidgets/QHeaderView \ - /usr/include/qt5/QtWidgets/qheaderview.h \ - /usr/include/qt5/QtWidgets/qabstractitemview.h \ - /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ - /usr/include/qt5/QtWidgets/qframe.h \ - /usr/include/qt5/QtCore/qabstractitemmodel.h \ - /usr/include/qt5/QtCore/qitemselectionmodel.h \ - /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ - /usr/include/qt5/QtWidgets/qstyleoption.h \ - /usr/include/qt5/QtWidgets/qabstractspinbox.h \ - /usr/include/qt5/QtGui/qvalidator.h \ - /usr/include/qt5/QtWidgets/qslider.h \ - /usr/include/qt5/QtWidgets/qabstractslider.h \ - /usr/include/qt5/QtWidgets/qstyle.h \ - /usr/include/qt5/QtWidgets/qtabbar.h \ - /usr/include/qt5/QtWidgets/qrubberband.h \ - /usr/include/qt5/QtWidgets/QListWidget \ - /usr/include/qt5/QtWidgets/qlistwidget.h \ - /usr/include/qt5/QtWidgets/qlistview.h \ - /usr/include/qt5/QtWidgets/QMenu \ - /usr/include/qt5/QtWidgets/qmenu.h \ - /usr/include/qt5/QtWidgets/QMenuBar \ - /usr/include/qt5/QtWidgets/qmenubar.h \ - /usr/include/qt5/QtWidgets/QPushButton \ - /usr/include/qt5/QtWidgets/qpushbutton.h \ - /usr/include/qt5/QtWidgets/qabstractbutton.h \ - /usr/include/qt5/QtWidgets/QSplitter \ - /usr/include/qt5/QtWidgets/qsplitter.h \ - /usr/include/qt5/QtWidgets/QWidget \ - ../QChatClient/chatinputtext.h \ - /usr/include/qt5/QtWidgets/QTextEdit \ - /usr/include/qt5/QtWidgets/qtextedit.h \ - /usr/include/qt5/QtGui/qtextdocument.h \ - /usr/include/qt5/QtGui/qtextoption.h \ - /usr/include/qt5/QtGui/qtextcursor.h \ - /usr/include/qt5/QtGui/qtextformat.h \ - /usr/include/qt5/QtGui/qpen.h \ - /usr/include/qt5/QtGui/QKeyEvent \ - ../QChatClient/chatwidget.h + ui_chatroom.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o chatroom.o ../QChatClient/chatroom.cpp Socket.o: ../QChatClient/Socket.cpp ../QChatClient/Socket.h \ @@ -1981,7 +1918,14 @@ chatwidget.o: ../QChatClient/chatwidget.cpp ../QChatClient/chatwidget.h \ /usr/include/qt5/QtGui/qtextoption.h \ /usr/include/qt5/QtGui/qtextcursor.h \ /usr/include/qt5/QtGui/qtextformat.h \ - /usr/include/qt5/QtGui/qpen.h + /usr/include/qt5/QtGui/qpen.h \ + /usr/include/qt5/QtWidgets/QFileDialog \ + /usr/include/qt5/QtWidgets/qfiledialog.h \ + /usr/include/qt5/QtCore/qdir.h \ + /usr/include/qt5/QtCore/qfileinfo.h \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QFile \ + /usr/include/qt5/QtCore/QTextStream $(CXX) -c $(CXXFLAGS) $(INCPATH) -o chatwidget.o ../QChatClient/chatwidget.cpp chatwindow.o: ../QChatClient/chatwindow.cpp ../QChatClient/chatwindow.h \ @@ -2095,62 +2039,16 @@ chatwindow.o: ../QChatClient/chatwindow.cpp ../QChatClient/chatwindow.h \ /usr/include/qt5/QtGui/qtouchdevice.h \ /usr/include/qt5/QtWidgets/qtabwidget.h \ /usr/include/qt5/QtGui/qicon.h \ - ui_chatwindow.h \ - /usr/include/qt5/QtCore/QVariant \ - /usr/include/qt5/QtWidgets/QAction \ - /usr/include/qt5/QtWidgets/qaction.h \ - /usr/include/qt5/QtWidgets/qactiongroup.h \ - /usr/include/qt5/QtWidgets/QApplication \ - /usr/include/qt5/QtWidgets/qapplication.h \ - /usr/include/qt5/QtCore/qcoreapplication.h \ - /usr/include/qt5/QtCore/qeventloop.h \ - /usr/include/qt5/QtWidgets/qdesktopwidget.h \ - /usr/include/qt5/QtGui/qguiapplication.h \ - /usr/include/qt5/QtGui/qinputmethod.h \ - /usr/include/qt5/QtWidgets/QButtonGroup \ - /usr/include/qt5/QtWidgets/qbuttongroup.h \ - /usr/include/qt5/QtWidgets/QGridLayout \ - /usr/include/qt5/QtWidgets/qgridlayout.h \ - /usr/include/qt5/QtWidgets/qlayout.h \ - /usr/include/qt5/QtWidgets/qlayoutitem.h \ - /usr/include/qt5/QtWidgets/qboxlayout.h \ - /usr/include/qt5/QtWidgets/QHeaderView \ - /usr/include/qt5/QtWidgets/qheaderview.h \ - /usr/include/qt5/QtWidgets/qabstractitemview.h \ - /usr/include/qt5/QtWidgets/qabstractscrollarea.h \ - /usr/include/qt5/QtWidgets/qframe.h \ + ../QChatClient/chatroom.h \ + /usr/include/qt5/QtCore/QModelIndex \ /usr/include/qt5/QtCore/qabstractitemmodel.h \ - /usr/include/qt5/QtCore/qitemselectionmodel.h \ - /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \ - /usr/include/qt5/QtWidgets/qstyleoption.h \ - /usr/include/qt5/QtWidgets/qabstractspinbox.h \ - /usr/include/qt5/QtGui/qvalidator.h \ - /usr/include/qt5/QtWidgets/qslider.h \ - /usr/include/qt5/QtWidgets/qabstractslider.h \ - /usr/include/qt5/QtWidgets/qstyle.h \ - /usr/include/qt5/QtWidgets/qtabbar.h \ - /usr/include/qt5/QtWidgets/qrubberband.h \ - /usr/include/qt5/QtWidgets/QMenu \ - /usr/include/qt5/QtWidgets/qmenu.h \ - /usr/include/qt5/QtWidgets/QMenuBar \ - /usr/include/qt5/QtWidgets/qmenubar.h \ - /usr/include/qt5/QtWidgets/QPushButton \ - /usr/include/qt5/QtWidgets/qpushbutton.h \ - /usr/include/qt5/QtWidgets/qabstractbutton.h \ - /usr/include/qt5/QtWidgets/QSpacerItem \ - /usr/include/qt5/QtWidgets/QSplitter \ - /usr/include/qt5/QtWidgets/qsplitter.h \ - /usr/include/qt5/QtWidgets/QWidget \ - ../QChatClient/chatinputtext.h \ - /usr/include/qt5/QtWidgets/QTextEdit \ - /usr/include/qt5/QtWidgets/qtextedit.h \ - /usr/include/qt5/QtGui/qtextdocument.h \ - /usr/include/qt5/QtGui/qtextoption.h \ - /usr/include/qt5/QtGui/qtextcursor.h \ - /usr/include/qt5/QtGui/qtextformat.h \ - /usr/include/qt5/QtGui/qpen.h \ - /usr/include/qt5/QtGui/QKeyEvent \ - ../QChatClient/chatwidget.h + ../QChatClient/loginscreen.h \ + /usr/include/qt5/QtWidgets/QDialog \ + /usr/include/qt5/QtWidgets/qdialog.h \ + /usr/include/qt5/QtCore/QRegExp \ + ../QChatClient/Socket.h \ + ../QChatClient/SocketException.h \ + ui_chatwindow.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o chatwindow.o ../QChatClient/chatwindow.cpp chatinputtext.o: ../QChatClient/chatinputtext.cpp ../QChatClient/chatinputtext.h \ @@ -2269,7 +2167,9 @@ chatinputtext.o: ../QChatClient/chatinputtext.cpp ../QChatClient/chatinputtext.h /usr/include/qt5/QtGui/qtextcursor.h \ /usr/include/qt5/QtGui/qtextformat.h \ /usr/include/qt5/QtGui/qpen.h \ - /usr/include/qt5/QtGui/QKeyEvent + /usr/include/qt5/QtGui/QKeyEvent \ + /usr/include/qt5/QtCore/QTextCodec \ + /usr/include/qt5/QtCore/qtextcodec.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o chatinputtext.o ../QChatClient/chatinputtext.cpp moc_loginscreen.o: moc_loginscreen.cpp diff --git a/build-QChatClient-Desktop-Debug/QChatClient b/build-QChatClient-Desktop-Debug/QChatClient index 87b81ee..578e66e 100755 Binary files a/build-QChatClient-Desktop-Debug/QChatClient and b/build-QChatClient-Desktop-Debug/QChatClient differ diff --git a/build-QChatClient-Desktop-Debug/Socket.o b/build-QChatClient-Desktop-Debug/Socket.o index 9bc7c19..254b5da 100644 Binary files a/build-QChatClient-Desktop-Debug/Socket.o and b/build-QChatClient-Desktop-Debug/Socket.o differ diff --git a/build-QChatClient-Desktop-Debug/chatwidget.o b/build-QChatClient-Desktop-Debug/chatwidget.o index 66897aa..9d12ee2 100644 Binary files a/build-QChatClient-Desktop-Debug/chatwidget.o and b/build-QChatClient-Desktop-Debug/chatwidget.o differ diff --git a/build-QChatClient-Desktop-Debug/chatwindow.o b/build-QChatClient-Desktop-Debug/chatwindow.o index 4afe43a..ba8f827 100644 Binary files a/build-QChatClient-Desktop-Debug/chatwindow.o and b/build-QChatClient-Desktop-Debug/chatwindow.o differ diff --git a/build-QChatClient-Desktop-Debug/loginscreen.o b/build-QChatClient-Desktop-Debug/loginscreen.o index 06081e3..ea6eb09 100644 Binary files a/build-QChatClient-Desktop-Debug/loginscreen.o and b/build-QChatClient-Desktop-Debug/loginscreen.o differ diff --git a/build-QChatClient-Desktop-Debug/main.o b/build-QChatClient-Desktop-Debug/main.o index ef17633..caa5e80 100644 Binary files a/build-QChatClient-Desktop-Debug/main.o and b/build-QChatClient-Desktop-Debug/main.o differ diff --git a/build-QChatClient-Desktop-Debug/moc_chatroom.cpp b/build-QChatClient-Desktop-Debug/moc_chatroom.cpp index 1ae239a..c5114d2 100644 --- a/build-QChatClient-Desktop-Debug/moc_chatroom.cpp +++ b/build-QChatClient-Desktop-Debug/moc_chatroom.cpp @@ -19,8 +19,8 @@ QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_Chatroom_t { - QByteArrayData data[11]; - char stringdata[118]; + QByteArrayData data[13]; + char stringdata[134]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -32,19 +32,21 @@ static const qt_meta_stringdata_Chatroom_t qt_meta_stringdata_Chatroom = { QT_MOC_LITERAL(0, 0, 8), QT_MOC_LITERAL(1, 9, 15), QT_MOC_LITERAL(2, 25, 0), -QT_MOC_LITERAL(3, 26, 4), -QT_MOC_LITERAL(4, 31, 15), -QT_MOC_LITERAL(5, 47, 12), -QT_MOC_LITERAL(6, 60, 7), -QT_MOC_LITERAL(7, 68, 8), -QT_MOC_LITERAL(8, 77, 13), -QT_MOC_LITERAL(9, 91, 6), -QT_MOC_LITERAL(10, 98, 18) +QT_MOC_LITERAL(3, 26, 10), +QT_MOC_LITERAL(4, 37, 6), +QT_MOC_LITERAL(5, 44, 7), +QT_MOC_LITERAL(6, 52, 8), +QT_MOC_LITERAL(7, 61, 12), +QT_MOC_LITERAL(8, 74, 7), +QT_MOC_LITERAL(9, 82, 18), +QT_MOC_LITERAL(10, 101, 16), +QT_MOC_LITERAL(11, 118, 5), +QT_MOC_LITERAL(12, 124, 8) }, - "Chatroom\0threadsFinished\0\0exit\0" - "messagesToPrint\0startSession\0sendMsg\0" - "printMsg\0finishThreads\0finish\0" - "disconnectChatroom\0" + "Chatroom\0messagesToPrint\0\0createChat\0" + "sender\0newChat\0peerNick\0startSession\0" + "sendMsg\0disconnectChatroom\0launchChatWindow\0" + "index\0printMsg\0" }; #undef QT_MOC_LITERAL @@ -62,27 +64,27 @@ static const uint qt_meta_data_Chatroom[] = { 2, // signalCount // signals: name, argc, parameters, tag, flags - 1, 1, 54, 2, 0x05, - 4, 0, 57, 2, 0x05, + 1, 0, 54, 2, 0x05, + 3, 1, 55, 2, 0x05, // slots: name, argc, parameters, tag, flags - 5, 0, 58, 2, 0x0a, - 6, 0, 59, 2, 0x0a, - 7, 0, 60, 2, 0x0a, - 8, 1, 61, 2, 0x08, - 9, 0, 64, 2, 0x08, - 10, 0, 65, 2, 0x08, + 5, 1, 58, 2, 0x08, + 7, 0, 61, 2, 0x0a, + 8, 0, 62, 2, 0x0a, + 9, 0, 63, 2, 0x0a, + 10, 1, 64, 2, 0x0a, + 12, 0, 67, 2, 0x08, // signals: parameters - QMetaType::Void, QMetaType::Bool, 3, QMetaType::Void, + QMetaType::Void, QMetaType::QString, 4, // slots: parameters + QMetaType::Void, QMetaType::QString, 6, QMetaType::Void, QMetaType::Void, QMetaType::Void, - QMetaType::Void, QMetaType::Bool, 3, - QMetaType::Void, + QMetaType::Void, QMetaType::QModelIndex, 11, QMetaType::Void, 0 // eod @@ -93,28 +95,28 @@ void Chatroom::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, vo if (_c == QMetaObject::InvokeMetaMethod) { Chatroom *_t = static_cast(_o); switch (_id) { - case 0: _t->threadsFinished((*reinterpret_cast< bool(*)>(_a[1]))); break; - case 1: _t->messagesToPrint(); break; - case 2: _t->startSession(); break; - case 3: _t->sendMsg(); break; - case 4: _t->printMsg(); break; - case 5: _t->finishThreads((*reinterpret_cast< bool(*)>(_a[1]))); break; - case 6: _t->finish(); break; - case 7: _t->disconnectChatroom(); break; + case 0: _t->messagesToPrint(); break; + case 1: _t->createChat((*reinterpret_cast< QString(*)>(_a[1]))); break; + case 2: _t->newChat((*reinterpret_cast< QString(*)>(_a[1]))); break; + case 3: _t->startSession(); break; + case 4: _t->sendMsg(); break; + case 5: _t->disconnectChatroom(); break; + case 6: _t->launchChatWindow((*reinterpret_cast< QModelIndex(*)>(_a[1]))); break; + case 7: _t->printMsg(); break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast(_a[0]); void **func = reinterpret_cast(_a[1]); { - typedef void (Chatroom::*_t)(bool ); - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Chatroom::threadsFinished)) { + typedef void (Chatroom::*_t)(); + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Chatroom::messagesToPrint)) { *result = 0; } } { - typedef void (Chatroom::*_t)(); - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Chatroom::messagesToPrint)) { + typedef void (Chatroom::*_t)(QString ); + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Chatroom::createChat)) { *result = 1; } } @@ -158,15 +160,15 @@ int Chatroom::qt_metacall(QMetaObject::Call _c, int _id, void **_a) } // SIGNAL 0 -void Chatroom::threadsFinished(bool _t1) +void Chatroom::messagesToPrint() { - void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; - QMetaObject::activate(this, &staticMetaObject, 0, _a); + QMetaObject::activate(this, &staticMetaObject, 0, 0); } // SIGNAL 1 -void Chatroom::messagesToPrint() +void Chatroom::createChat(QString _t1) { - QMetaObject::activate(this, &staticMetaObject, 1, 0); + void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; + QMetaObject::activate(this, &staticMetaObject, 1, _a); } QT_END_MOC_NAMESPACE diff --git a/build-QChatClient-Desktop-Debug/moc_chatroom.o b/build-QChatClient-Desktop-Debug/moc_chatroom.o index fc639f9..f1b49de 100644 Binary files a/build-QChatClient-Desktop-Debug/moc_chatroom.o and b/build-QChatClient-Desktop-Debug/moc_chatroom.o differ diff --git a/build-QChatClient-Desktop-Debug/moc_chatwidget.cpp b/build-QChatClient-Desktop-Debug/moc_chatwidget.cpp index 0c66a61..d5554eb 100644 --- a/build-QChatClient-Desktop-Debug/moc_chatwidget.cpp +++ b/build-QChatClient-Desktop-Debug/moc_chatwidget.cpp @@ -19,8 +19,8 @@ QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_ChatWidget_t { - QByteArrayData data[1]; - char stringdata[12]; + QByteArrayData data[3]; + char stringdata[28]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -29,9 +29,11 @@ struct qt_meta_stringdata_ChatWidget_t { ) static const qt_meta_stringdata_ChatWidget_t qt_meta_stringdata_ChatWidget = { { -QT_MOC_LITERAL(0, 0, 10) +QT_MOC_LITERAL(0, 0, 10), +QT_MOC_LITERAL(1, 11, 14), +QT_MOC_LITERAL(2, 26, 0) }, - "ChatWidget\0" + "ChatWidget\0saveChatToFile\0\0" }; #undef QT_MOC_LITERAL @@ -41,21 +43,31 @@ static const uint qt_meta_data_ChatWidget[] = { 7, // revision 0, // classname 0, 0, // classinfo - 0, 0, // methods + 1, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount + // slots: name, argc, parameters, tag, flags + 1, 0, 19, 2, 0x0a, + + // slots: parameters + QMetaType::Void, + 0 // eod }; void ChatWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { - Q_UNUSED(_o); - Q_UNUSED(_id); - Q_UNUSED(_c); + if (_c == QMetaObject::InvokeMetaMethod) { + ChatWidget *_t = static_cast(_o); + switch (_id) { + case 0: _t->saveChatToFile(); break; + default: ; + } + } Q_UNUSED(_a); } @@ -83,6 +95,15 @@ int ChatWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) _id = QTextEdit::qt_metacall(_c, _id, _a); if (_id < 0) return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < 1) + qt_static_metacall(this, _c, _id, _a); + _id -= 1; + } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { + if (_id < 1) + *reinterpret_cast(_a[0]) = -1; + _id -= 1; + } return _id; } QT_END_MOC_NAMESPACE diff --git a/build-QChatClient-Desktop-Debug/moc_chatwidget.o b/build-QChatClient-Desktop-Debug/moc_chatwidget.o index 5da1b57..ef99011 100644 Binary files a/build-QChatClient-Desktop-Debug/moc_chatwidget.o and b/build-QChatClient-Desktop-Debug/moc_chatwidget.o differ diff --git a/build-QChatClient-Desktop-Debug/moc_chatwindow.cpp b/build-QChatClient-Desktop-Debug/moc_chatwindow.cpp index 8b57732..baa355a 100644 --- a/build-QChatClient-Desktop-Debug/moc_chatwindow.cpp +++ b/build-QChatClient-Desktop-Debug/moc_chatwindow.cpp @@ -19,8 +19,8 @@ QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_ChatWindow_t { - QByteArrayData data[1]; - char stringdata[12]; + QByteArrayData data[7]; + char stringdata[49]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -29,9 +29,16 @@ struct qt_meta_stringdata_ChatWindow_t { ) static const qt_meta_stringdata_ChatWindow_t qt_meta_stringdata_ChatWindow = { { -QT_MOC_LITERAL(0, 0, 10) +QT_MOC_LITERAL(0, 0, 10), +QT_MOC_LITERAL(1, 11, 10), +QT_MOC_LITERAL(2, 22, 0), +QT_MOC_LITERAL(3, 23, 3), +QT_MOC_LITERAL(4, 27, 7), +QT_MOC_LITERAL(5, 35, 8), +QT_MOC_LITERAL(6, 44, 3) }, - "ChatWindow\0" + "ChatWindow\0msgToPrint\0\0msg\0sendMsg\0" + "printMsg\0str\0" }; #undef QT_MOC_LITERAL @@ -41,22 +48,50 @@ static const uint qt_meta_data_ChatWindow[] = { 7, // revision 0, // classname 0, 0, // classinfo - 0, 0, // methods + 3, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags - 0, // signalCount + 1, // signalCount + + // signals: name, argc, parameters, tag, flags + 1, 1, 29, 2, 0x05, + + // slots: name, argc, parameters, tag, flags + 4, 0, 32, 2, 0x0a, + 5, 1, 33, 2, 0x08, + + // signals: parameters + QMetaType::Void, QMetaType::QString, 3, + + // slots: parameters + QMetaType::Void, + QMetaType::Void, QMetaType::QString, 6, 0 // eod }; void ChatWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { - Q_UNUSED(_o); - Q_UNUSED(_id); - Q_UNUSED(_c); - Q_UNUSED(_a); + if (_c == QMetaObject::InvokeMetaMethod) { + ChatWindow *_t = static_cast(_o); + switch (_id) { + case 0: _t->msgToPrint((*reinterpret_cast< QString(*)>(_a[1]))); break; + case 1: _t->sendMsg(); break; + case 2: _t->printMsg((*reinterpret_cast< QString(*)>(_a[1]))); break; + default: ; + } + } else if (_c == QMetaObject::IndexOfMethod) { + int *result = reinterpret_cast(_a[0]); + void **func = reinterpret_cast(_a[1]); + { + typedef void (ChatWindow::*_t)(QString ); + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&ChatWindow::msgToPrint)) { + *result = 0; + } + } + } } const QMetaObject ChatWindow::staticMetaObject = { @@ -83,6 +118,22 @@ int ChatWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; + if (_c == QMetaObject::InvokeMetaMethod) { + if (_id < 3) + qt_static_metacall(this, _c, _id, _a); + _id -= 3; + } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { + if (_id < 3) + *reinterpret_cast(_a[0]) = -1; + _id -= 3; + } return _id; } + +// SIGNAL 0 +void ChatWindow::msgToPrint(QString _t1) +{ + void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) }; + QMetaObject::activate(this, &staticMetaObject, 0, _a); +} QT_END_MOC_NAMESPACE diff --git a/build-QChatClient-Desktop-Debug/moc_chatwindow.o b/build-QChatClient-Desktop-Debug/moc_chatwindow.o index 7790e5b..77b2ef6 100644 Binary files a/build-QChatClient-Desktop-Debug/moc_chatwindow.o and b/build-QChatClient-Desktop-Debug/moc_chatwindow.o differ diff --git a/build-QChatClient-Desktop-Debug/moc_loginscreen.o b/build-QChatClient-Desktop-Debug/moc_loginscreen.o index f4b685d..8cc9dbc 100644 Binary files a/build-QChatClient-Desktop-Debug/moc_loginscreen.o and b/build-QChatClient-Desktop-Debug/moc_loginscreen.o differ diff --git a/build-QChatClient-Desktop-Debug/ui_chatroom.h b/build-QChatClient-Desktop-Debug/ui_chatroom.h index 27fee6a..c355dd4 100644 --- a/build-QChatClient-Desktop-Debug/ui_chatroom.h +++ b/build-QChatClient-Desktop-Debug/ui_chatroom.h @@ -33,6 +33,7 @@ public: QAction *actionConnect; QAction *actionExit; QAction *actionDisconnect; + QAction *actionSave_chat; QWidget *centralwidget; QGridLayout *gridLayout_2; QSplitter *windowSplitter; @@ -57,6 +58,9 @@ public: actionExit->setObjectName(QStringLiteral("actionExit")); actionDisconnect = new QAction(Chatroom); actionDisconnect->setObjectName(QStringLiteral("actionDisconnect")); + actionDisconnect->setEnabled(false); + actionSave_chat = new QAction(Chatroom); + actionSave_chat->setObjectName(QStringLiteral("actionSave_chat")); centralwidget = new QWidget(Chatroom); centralwidget->setObjectName(QStringLiteral("centralwidget")); gridLayout_2 = new QGridLayout(centralwidget); @@ -75,7 +79,7 @@ public: chatSplitter->setOrientation(Qt::Vertical); chatText = new ChatWidget(chatSplitter); chatText->setObjectName(QStringLiteral("chatText")); - chatText->setReadOnly(false); + chatText->setReadOnly(true); chatSplitter->addWidget(chatText); inputText = new chatInputText(chatSplitter); inputText->setObjectName(QStringLiteral("inputText")); @@ -106,6 +110,7 @@ public: sendButton = new QPushButton(centralwidget); sendButton->setObjectName(QStringLiteral("sendButton")); + sendButton->setEnabled(false); QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy2.setHorizontalStretch(0); sizePolicy2.setVerticalStretch(0); @@ -121,10 +126,14 @@ public: menuChat = new QMenu(menuBar); menuChat->setObjectName(QStringLiteral("menuChat")); Chatroom->setMenuBar(menuBar); + QWidget::setTabOrder(chatText, inputText); + QWidget::setTabOrder(inputText, userList); + QWidget::setTabOrder(userList, sendButton); menuBar->addAction(menuChat->menuAction()); menuChat->addAction(actionConnect); menuChat->addAction(actionDisconnect); + menuChat->addAction(actionSave_chat); menuChat->addAction(actionExit); retranslateUi(Chatroom); @@ -138,6 +147,7 @@ public: actionConnect->setText(QApplication::translate("Chatroom", "Connect...", 0)); actionExit->setText(QApplication::translate("Chatroom", "Exit", 0)); actionDisconnect->setText(QApplication::translate("Chatroom", "Disconnect", 0)); + actionSave_chat->setText(QApplication::translate("Chatroom", "Save chat...", 0)); sendButton->setText(QApplication::translate("Chatroom", "Send", 0)); menuChat->setTitle(QApplication::translate("Chatroom", "Chat", 0)); } // retranslateUi diff --git a/build-QChatClient-Desktop-Debug/ui_chatwindow.h b/build-QChatClient-Desktop-Debug/ui_chatwindow.h index 3b205c2..61c3ad1 100644 --- a/build-QChatClient-Desktop-Debug/ui_chatwindow.h +++ b/build-QChatClient-Desktop-Debug/ui_chatwindow.h @@ -31,6 +31,7 @@ class Ui_ChatWindow { public: QAction *actionExit; + QAction *actionSave_chat; QWidget *centralWidget; QGridLayout *gridLayout; QSpacerItem *horizontalSpacer; @@ -50,6 +51,8 @@ public: ChatWindow->resize(400, 502); actionExit = new QAction(ChatWindow); actionExit->setObjectName(QStringLiteral("actionExit")); + actionSave_chat = new QAction(ChatWindow); + actionSave_chat->setObjectName(QStringLiteral("actionSave_chat")); centralWidget = new QWidget(ChatWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); centralWidget->setEnabled(true); @@ -100,7 +103,7 @@ public: inputText->setMinimumSize(QSize(0, 0)); inputText->setMaximumSize(QSize(16777215, 16777215)); inputText->setBaseSize(QSize(0, 0)); - inputText->setReadOnly(true); + inputText->setReadOnly(false); splitter->addWidget(inputText); gridLayout_2->addWidget(splitter, 0, 0, 1, 1); @@ -115,8 +118,11 @@ public: menuChat = new QMenu(menuBar); menuChat->setObjectName(QStringLiteral("menuChat")); ChatWindow->setMenuBar(menuBar); + QWidget::setTabOrder(chatText, inputText); + QWidget::setTabOrder(inputText, sendButton); menuBar->addAction(menuChat->menuAction()); + menuChat->addAction(actionSave_chat); menuChat->addAction(actionExit); retranslateUi(ChatWindow); @@ -128,6 +134,7 @@ public: { ChatWindow->setWindowTitle(QApplication::translate("ChatWindow", "QChatClient", 0)); actionExit->setText(QApplication::translate("ChatWindow", "Exit", 0)); + actionSave_chat->setText(QApplication::translate("ChatWindow", "Save chat...", 0)); sendButton->setText(QApplication::translate("ChatWindow", "Send", 0)); menuChat->setTitle(QApplication::translate("ChatWindow", "Chat", 0)); } // retranslateUi -- libgit2 0.22.2