Repository navigation
Expand file tree
/
Copy pathServerRoom.cpp
More file actions
152 lines (138 loc) · 3.33 KB
/
Copy pathServerRoom.cpp
File metadata and controls
152 lines (138 loc) · 3.33 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/**
* @class ServerRoom
* @brief about the ServerRoom class
*/
#include "ServerRoom.h"
#include "ui_serverroom.h"
/**
* @brief Constructor for ServerRoom::ServerRoom
* @param parent Passed to QDialog constructor.
*/
ServerRoom::ServerRoom(QWidget *parent) :
QDialog(parent),
ui(new Ui::ServerRoom)
{
ui->setupUi(this);
ui->userList->hide();
ui->roomIpLabel->hide();
ui->roomPortLabel->hide();
ui->disconnectButton->hide();
ui->collaboratorsLabel->hide();
}
/**
* @brief Destructor for ServerRoom::~ServerRoom
*/
ServerRoom::~ServerRoom()
{
delete ui;
}
/**
* @brief set-up for Create Room
*/
void ServerRoom::setCreateRoom() {
ui->addressLine->hide();
ui->addressLabel->hide();
ui->portLine->hide();
ui->portLabel->hide();
ui->joinRoomButtonBox->hide();
ui->titleLabel->setText("Create Room");
}
/**
* @brief set-up for Join Room
*/
void ServerRoom::setJoinRoom() {
ui->createRoomButtonBox->hide();
ui->titleLabel->setText("Join Room");
ui->nameLine->show();
ui->nameLabel->show();
ui->addressLine->show();
ui->addressLabel->show();
ui->portLine->show();
ui->portLabel->show();
ui->joinRoomButtonBox->show();
ui->userList->hide();
ui->roomIpLabel->hide();
ui->ipContent->hide();
ui->roomPortLabel->hide();
ui->portContent->hide();
ui->disconnectButton->hide();
ui->collaboratorsLabel->hide();
}
/**
* @brief set-up for Server Room
* @param ip IP Address
* @param port Port
*/
void ServerRoom::setServerRoom(QString ip, quint16 port) {
ui->nameLine->hide();
ui->nameLabel->hide();
ui->addressLine->hide();
ui->addressLabel->hide();
ui->portLine->hide();
ui->portLabel->hide();
ui->joinRoomButtonBox->hide();
ui->createRoomButtonBox->hide();
ui->userList->show();
ui->roomIpLabel->show();
ui->roomPortLabel->show();
ui->ipContent->show();
ui->ipContent->setText(ip);
ui->portContent->show();
ui->portContent->setNum(port);
ui->disconnectButton->show();
ui->collaboratorsLabel->show();
ui->titleLabel->setText("The Room");
}
/**
* @brief Handling join room
* @details emit joinRoom signal with name, address, and port
*/
void ServerRoom::on_joinRoomButtonBox_accepted()
{
QString name = ui->nameLine->text().simplified();
QString address = ui->addressLine->text().simplified();
quint16 port = ui->portLine->text().simplified().toUShort();
emit joinRoom(name, address, port);
}
/**
* @brief Handling create room
* @details emit createRoom signal with name (slot at MainWindow)
*/
void ServerRoom::on_createRoomButtonBox_accepted()
{
QString name = ui->nameLine->text().simplified();
emit createRoom(name);
}
/**
* @brief adds User to user list.
*/
void ServerRoom::addUser(QString name) {
ui->userList->addItem(name);
}
/**
* @brief clears all users from the user list.
*/
void ServerRoom::emptyUsers() {
ui->userList->clear();
}
/**
* @brief close if joinRoomButtonBox is rejected
*/
void ServerRoom::on_joinRoomButtonBox_rejected()
{
close();
}
/**
* @brief close if createRoomButtonBox is rejected
*/
void ServerRoom::on_createRoomButtonBox_rejected()
{
close();
}
/**
* @brief If disconnectButton is clicked, emit disconnect signal (slot at MainWindow)
*/
void ServerRoom::on_disconnectButton_clicked()
{
emit disconnect();
}