forked from markopoloparadox/ProjectPerun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddFriendWindow.cpp
42 lines (34 loc) · 1.16 KB
/
AddFriendWindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "AddFriendWindow.h"
#include "MainWindow.h"
AddFriendWindow::AddFriendWindow(QTcpSocket *socket, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AddFriendWindow),
socket(socket)
{
ui->setupUi(this);
this->setWindowFlags(Qt::Dialog);
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(this->ui->cancelButton, SIGNAL(clicked(bool)), this, SLOT(close()));
}
AddFriendWindow::~AddFriendWindow() {
((MainWindow*)this->parent())->addFriendBox = NULL;
delete this->ui;
}
void AddFriendWindow::on_addButton_clicked() {
QJsonObject object;
QJsonDocument document;
QByteArray packet;
QString username;
username = this->ui->emailLineEdit->text();
if(username.isEmpty()) {
this->ui->statusLabel->setText("Please enter all the information!");
this->ui->statusLabel->setStyleSheet("QLabel { background-color : white; color : blue; }");
return;
}
object["connection"] = "0008";
object["email"] = username;
document.setObject(object);
packet = (document.toJson(QJsonDocument::Compact));
this->socket->write(packet);
this->socket->flush();
}