-
Notifications
You must be signed in to change notification settings - Fork 3
/
connect.cpp
108 lines (86 loc) · 2.37 KB
/
connect.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
99
100
101
102
103
104
105
106
107
108
#ifdef ONLINE_PLAY
#include "connect.h"
#include "ui_connect.h"
#include <QMessageBox>
Connect::Connect(QWidget *parent) :
QDialog(parent),
ui(new Ui::Connect)
{
warning_accepted = false;
warning_disabled = false;
UnRegistered = true;
ui->setupUi(this);
button_Register = new QPushButton(tr("Register"));
ui->buttonBox->addButton(button_Register, QDialogButtonBox::AcceptRole);
button_Connect = new QPushButton(tr("Connect 2"));
button_Connect->setDefault(true);
ui->buttonBox->addButton(button_Connect, QDialogButtonBox::AcceptRole);
button_Cancel = new QPushButton(tr("Cancel"));
ui->buttonBox->addButton(button_Cancel, QDialogButtonBox::RejectRole);
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(diagButtonClicked(QAbstractButton*)));
}
Connect::~Connect()
{
delete ui;
delete button_Register;
delete button_Connect;
delete button_Cancel;
}
QString Connect::getHost()
{
return ui->lineEdit->text();
}
QString Connect::getPort()
{
return ui->lineEdit_2->text();
}
QString Connect::getHandle()
{
return ui->lineEdit_3->text();
}
QString Connect::getPassword()
{
return ui->lineEdit_4->text();
}
void Connect::config(QString &username, QString &password, bool warning)
{
ui->lineEdit_3->setText(username);
ui->lineEdit_4->setText(password);
if (!warning) {
warning_disabled = true;
ui->checkBox->hide();
}
}
void Connect::diagButtonClicked(QAbstractButton* button)
{
if (!warning_disabled && ((button == button_Register) || (button == button_Connect))) {
QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Warning!"));
msgBox.setText(tr("The password will be sent unencrypted over the internet.\r\nIt is also saved unencrypted in ~/.hearts\r\n\r\n"
"DON'T reuse this password !\r\n\r\nDo you want to continue ?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
if (msgBox.exec() == QMessageBox::Yes)
warning_accepted = true;
}
if (button == button_Connect)
UnRegistered = false;
}
void Connect::on_checkBox_clicked()
{
warning_disabled = true;
ui->checkBox->hide();
}
bool Connect::WarningAccepted()
{
return warning_disabled ? true : warning_accepted;
}
bool Connect::WarningDisabled()
{
return warning_disabled;
}
bool Connect::isUnRegistered()
{
return UnRegistered;
}
#endif // ONLINE_PLAY