-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetuptcpdialog.cpp
98 lines (73 loc) · 1.87 KB
/
setuptcpdialog.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
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
#include "setuptcpdialog.h"
#include "ui_setuptcpdialog.h"
SetupTcpDialog::SetupTcpDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SetupTcpDialog)
{
ui->setupUi(this);
ui->lineEditIPAdress->setInputMask("000.000.000.000");
defaultIpAdress = "10.10.100.254";
defaultPortNumber = 8899;
setIpAdress(defaultIpAdress);
setPortNumber(defaultPortNumber);
setDefaultValue();
ui->checkBox->setChecked(true);
}
SetupTcpDialog::~SetupTcpDialog()
{
delete ui;
}
void SetupTcpDialog::on_pushButton_clicked()
{
updateIpAndPort();
ipAdress = ui->lineEditIPAdress->text();
portNumber = ui->lineEditPortNumber->text().toInt();
emit newIpAndPort(ipAdress, portNumber);
this->hide();
}
void SetupTcpDialog::on_checkBox_clicked()
{
setDefaultValue();
}
void SetupTcpDialog::setDefaultValue()
{
if(ui->lineEditIPAdress->isEnabled())
{
ui->lineEditIPAdress->setEnabled(false);
ui->lineEditPortNumber->setEnabled(false);
ui->lineEditIPAdress->setText(defaultIpAdress);
ui->lineEditPortNumber->setText(QString::number(defaultPortNumber));
ipAdress = ui->lineEditIPAdress->text();
portNumber = ui->lineEditPortNumber->text().toInt();
}
else
{
ui->lineEditIPAdress->setEnabled(true);
ui->lineEditPortNumber->setEnabled(true);
}
}
void SetupTcpDialog::updateIpAndPort()
{
ipAdress = ui->lineEditIPAdress->text();
portNumber = ui->lineEditPortNumber->text().toInt();
}
quint16 SetupTcpDialog::getPortNumber() const
{
return portNumber;
}
void SetupTcpDialog::setPortNumber(const quint16 &value)
{
portNumber = value;
}
QString SetupTcpDialog::getIpAdress() const
{
return ipAdress;
}
void SetupTcpDialog::setIpAdress(const QString &value)
{
ipAdress = value;
}
void SetupTcpDialog::on_pushButton_2_clicked()
{
this->hide();
}