forked from KangLin/RabbitRemoteControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDlgInputPassword.cpp
More file actions
61 lines (52 loc) · 1.58 KB
/
DlgInputPassword.cpp
File metadata and controls
61 lines (52 loc) · 1.58 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
// Author: Kang Lin <kl222@126.com>
#include "DlgInputPassword.h"
#include "ui_DlgInputPassword.h"
#include "ManagePassword.h"
CDlgInputPassword::CDlgInputPassword(QString szTitle, QWidget *parent) :
QDialog(parent),
ui(new Ui::CDlgInputPassword)
{
ui->setupUi(this);
ui->pbShow->setEnabled(CManagePassword::Instance()->GetViewPassowrd());
setWindowTitle(tr("Input encrypt key"));
QString szDescript = tr("The encryption key is used to encrypt the password that is saved to the file.");
if(!szTitle.isEmpty())
szDescript += tr("If you forget the encryption key, please use input %1.").arg(szTitle);
ui->lbDescript->setText(szDescript);
if(szTitle.isEmpty())
ui->rbPassword->setVisible(false);
ui->rbPassword->setText(tr("Input %1").arg(szTitle));
}
CDlgInputPassword::~CDlgInputPassword()
{
delete ui;
}
void CDlgInputPassword::on_pbNo_clicked()
{
reject();
}
void CDlgInputPassword::on_pbYes_clicked()
{
accept();
}
int CDlgInputPassword::GetValue(InputType &t, QString &password)
{
if(ui->rbKey->isChecked()) t = Encrypt;
if(ui->rbPassword->isChecked()) t = Password;
password = ui->lePassword->text();
return 0;
}
void CDlgInputPassword::on_pbShow_clicked()
{
switch(ui->lePassword->echoMode())
{
case QLineEdit::Password:
ui->lePassword->setEchoMode(QLineEdit::Normal);
ui->pbShow->setIcon(QIcon(":/image/EyeOff"));
break;
case QLineEdit::Normal:
ui->lePassword->setEchoMode(QLineEdit::Password);
ui->pbShow->setIcon(QIcon(":/image/EyeOn"));
break;
}
}