-
Notifications
You must be signed in to change notification settings - Fork 6
/
addnodedialog.cpp
91 lines (72 loc) · 2.75 KB
/
addnodedialog.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
#include "addnodedialog.h"
#include "ui_addnodedialog.h"
#include "goopal.h"
AddNodeDialog::AddNodeDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddNodeDialog)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
setStyleSheet("#AddNodeDialog{background-color: rgb(246, 246, 246);border:1px groove rgb(180,180,180);}");
ui->addBtn->setStyleSheet("QToolButton{background-color:#4dc8cf;color:#ffffff;border:0px solid rgb(64,153,255);border-radius:3px;}"
"QToolButton:hover{background-color:#7dd9df;}"
"QToolButton:disabled{background-color:#cecece;}");
ui->addBtn->setEnabled(false);
ui->cancelBtn->setStyleSheet("QToolButton{background-color:#ffffff;color:#282828;border:1px solid #7dd9df;border-radius:3px;}"
"QToolButton:hover{color:#7dd9df;}");
ui->ipLineEdit->setStyleSheet("color:black;border:1px solid #CCCCCC;border-radius:3px;");
ui->ipLineEdit->setTextMargins(8,0,0,0);
ui->ipLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false);
ui->portLineEdit->setStyleSheet("color:black;border:1px solid #CCCCCC;border-radius:3px;");
ui->portLineEdit->setTextMargins(8,0,0,0);
ui->portLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false);
QRegExp regx("[0-9\.]+$");
QValidator *validator = new QRegExpValidator(regx, this);
ui->ipLineEdit->setValidator( validator );
QRegExp regx2("[0-9]+$");
QValidator *validator2 = new QRegExpValidator(regx2, this);
ui->portLineEdit->setValidator( validator2 );
}
AddNodeDialog::~AddNodeDialog()
{
delete ui;
}
void AddNodeDialog::on_cancelBtn_clicked()
{
close();
}
void AddNodeDialog::on_addBtn_clicked()
{
// RpcThread* rpcThread = new RpcThread;
// connect(rpcThread,SIGNAL(finished()),rpcThread,SLOT(deleteLater()));
// rpcThread->setWriteData( toJsonFormat( "id_addnode", "addnode", QStringList() << ui->ipLineEdit->text() + ":" + ui->portLineEdit->text() << "add" ));
// rpcThread->start();
// Goopal::getInstance()->postRPC( toJsonFormat( "id_addnode", "addnode", QStringList() << ui->ipLineEdit->text() + ":" + ui->portLineEdit->text() << "add" ));
close();
}
void AddNodeDialog::on_portLineEdit_returnPressed()
{
on_addBtn_clicked();
}
void AddNodeDialog::on_ipLineEdit_textChanged(const QString &arg1)
{
if( !arg1.isEmpty() && !ui->portLineEdit->text().isEmpty())
{
ui->addBtn->setEnabled(true);
}
else
{
ui->addBtn->setEnabled(false);
}
}
void AddNodeDialog::on_portLineEdit_textChanged(const QString &arg1)
{
if( !arg1.isEmpty() && !ui->ipLineEdit->text().isEmpty())
{
ui->addBtn->setEnabled(true);
}
else
{
ui->addBtn->setEnabled(false);
}
}