-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chat Incorporated , Checkpointed , Important Links Drop Down Menu Add…
…ed , UI Improvements , Anon Base Implemented.
- Loading branch information
1 parent
a965cd3
commit 4d1d0d4
Showing
74 changed files
with
2,189 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "ChatWindow.h" | ||
|
||
#include <QRegExp> | ||
|
||
ChatWindow::ChatWindow(QWidget *parent) : QMainWindow(parent) | ||
{ | ||
setupUi(this); | ||
|
||
stackedWidget->setCurrentWidget(loginPage); | ||
|
||
socket = new QTcpSocket(this); | ||
|
||
connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead())); | ||
connect(socket, SIGNAL(connected()), this, SLOT(connected())); | ||
} | ||
|
||
void ChatWindow::on_loginButton_clicked() | ||
{ | ||
socket->connectToHost(serverLineEdit->text(), 4200); | ||
} | ||
|
||
void ChatWindow::on_sayButton_clicked() | ||
{ | ||
QString message = sayLineEdit->text().trimmed(); | ||
|
||
if(!message.isEmpty()) | ||
{ | ||
socket->write(QString(message + "\n").toUtf8()); | ||
} | ||
|
||
sayLineEdit->clear(); | ||
|
||
sayLineEdit->setFocus(); | ||
} | ||
|
||
void ChatWindow::readyRead() | ||
{ | ||
while(socket->canReadLine()) | ||
{ | ||
QString line = QString::fromUtf8(socket->readLine()).trimmed(); | ||
|
||
QRegExp messageRegex("^([^:]+):(.*)$"); | ||
|
||
QRegExp usersRegex("^/users:(.*)$"); | ||
|
||
if(usersRegex.indexIn(line) != -1) | ||
{ | ||
QStringList users = usersRegex.cap(1).split(","); | ||
userListWidget->clear(); | ||
foreach(QString user, users) | ||
new QListWidgetItem(QPixmap(":/res/icons/user.png"), user, userListWidget); | ||
} | ||
else if(messageRegex.indexIn(line) != -1) | ||
{ | ||
QString user = messageRegex.cap(1); | ||
QString message = messageRegex.cap(2); | ||
|
||
roomTextEdit->append("<b>" + user + "</b>: " + message); | ||
} | ||
} | ||
} | ||
|
||
void ChatWindow::connected() | ||
{ | ||
stackedWidget->setCurrentWidget(chatPage); | ||
|
||
socket->write(QString("/me:" + userLineEdit->text() + "\n").toUtf8()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <QMainWindow> | ||
#include <QTcpSocket> | ||
|
||
#include "ui_ChatWindow.h" | ||
|
||
class ChatWindow : public QMainWindow, public Ui::ChatWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
ChatWindow(QWidget *parent=0); | ||
|
||
private slots: | ||
|
||
void on_loginButton_clicked(); | ||
|
||
void on_sayButton_clicked(); | ||
|
||
void readyRead(); | ||
|
||
void connected(); | ||
|
||
private: | ||
|
||
QTcpSocket *socket; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.