-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteaccountdialog.cpp
145 lines (112 loc) · 4 KB
/
deleteaccountdialog.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
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
#include "deleteaccountdialog.h"
#include "ui_deleteaccountdialog.h"
#include "blockchain.h"
#include "debug_log.h"
#include <QDebug>
#include <QFocusEvent>
DeleteAccountDialog::DeleteAccountDialog(QString name , QWidget *parent) :
QDialog(parent),
accountName(name),
yesOrNo( false),
ui(new Ui::DeleteAccountDialog)
{
DLOG_QT_WALLET_FUNCTION_BEGIN;
ui->setupUi(this);
// Fry::getInstance()->appendCurrentDialogVector(this);
setParent(Blockchain::getInstance()->mainFrame);
setAttribute(Qt::WA_TranslucentBackground, true);
setWindowFlags(Qt::FramelessWindowHint);
ui->widget->setObjectName("widget");
ui->widget->setStyleSheet("#widget {background-color:rgba(10, 10, 10,100);}");
ui->containerWidget->setObjectName("containerwidget");
ui->containerWidget->setStyleSheet("#containerwidget{background-color: rgb(246, 246, 246);border:1px groove rgb(180,180,180);}");
ui->pwdLineEdit->setStyleSheet("color:black;border:1px solid #CCCCCC;border-radius:3px;");
ui->pwdLineEdit->setPlaceholderText( tr("Login password"));
ui->pwdLineEdit->setTextMargins(8,0,0,0);
ui->pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false);
ui->okBtn->setText(tr("Ok"));
ui->cancelBtn->setText(tr("Cancel"));
ui->okBtn->setEnabled(false);
ui->pwdLineEdit->setFocus();
DLOG_QT_WALLET_FUNCTION_END;
}
DeleteAccountDialog::~DeleteAccountDialog()
{
DLOG_QT_WALLET_FUNCTION_BEGIN;
delete ui;
// Fry::getInstance()->removeCurrentDialogVector(this);
DLOG_QT_WALLET_FUNCTION_END;
}
void DeleteAccountDialog::on_okBtn_clicked()
{
DLOG_QT_WALLET_FUNCTION_BEGIN;
if( ui->pwdLineEdit->text().isEmpty()) return;
QString str = "wallet_check_passphrase " + ui->pwdLineEdit->text() + "\n";
Blockchain::getInstance()->write( str);
QString result = Blockchain::getInstance()->read();
if( result.mid(0,4) == "true")
{
Blockchain::getInstance()->write( "wallet_account_delete " + accountName + "\n");
QString result = Blockchain::getInstance()->read();
if( result.mid(0,4) == "true")
{
Blockchain::getInstance()->deleteAccountInConfigFile( accountName);
Blockchain::getInstance()->addressMapRemove( accountName);
Blockchain::getInstance()->balanceMapRemove( accountName);
Blockchain::getInstance()->registerMapRemove( accountName);
}
yesOrNo = true;
close();
// emit accepted();
}
else if( result.mid(0,5) == "false")
{
ui->tipLabel1->setPixmap(QPixmap(":/pic/pic2/wrong.png"));
ui->tipLabel2->setText("<body><font style=\"font-size:12px\" color=#FF8880>" + tr("Wrong Password!") + "</font></body>" );
}
else if( result.mid(0,5) == "20015")
{
ui->tipLabel1->setPixmap(QPixmap(":/pic/pic2/wrong.png"));
ui->tipLabel2->setText("<body><font style=\"font-size:12px\" color=#FF8880>" + tr("At least 8 letters!") + "</font></body>" );
}
DLOG_QT_WALLET_FUNCTION_END;
}
void DeleteAccountDialog::on_cancelBtn_clicked()
{
yesOrNo = false;
close();
// emit accepted();
}
void DeleteAccountDialog::on_pwdLineEdit_textChanged(const QString &arg1)
{
if( arg1.indexOf(' ') > -1)
{
ui->pwdLineEdit->setText( ui->pwdLineEdit->text().remove(' '));
return;
}
if( arg1.isEmpty())
{
ui->okBtn->setEnabled(false);
}
else
{
ui->okBtn->setEnabled(true);
}
ui->tipLabel1->setPixmap(QPixmap(""));
ui->tipLabel2->setText("");
}
bool DeleteAccountDialog::pop()
{
ui->pwdLineEdit->grabKeyboard();
// QEventLoop loop;
// show();
// connect(this,SIGNAL(accepted()),&loop,SLOT(quit()));
// loop.exec(); //进入事件 循环处理,阻塞
move(0,0);
exec();
return yesOrNo;
}
void DeleteAccountDialog::on_pwdLineEdit_returnPressed()
{
on_okBtn_clicked();
}