Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
DlgInputPassword.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "DlgInputPassword.h"
4#include "ui_DlgInputPassword.h"
5
6CDlgInputPassword::CDlgInputPassword(bool bShow, QString szTitle, QWidget *parent)
7 : QDialog(parent),
8 ui(new Ui::CDlgInputPassword)
9{
10 ui->setupUi(this);
11 ui->pbShow->setEnabled(bShow);
12 setWindowTitle(tr("Input encrypt key"));
13
14 QString szDescript = tr("The encryption key is used to encrypt the password that is saved to the file.");
15 if(!szTitle.isEmpty())
16 szDescript += tr("If you forget the encryption key, please use input %1.").arg(szTitle);
17 ui->lbDescript->setText(szDescript);
18 if(szTitle.isEmpty())
19 ui->rbPassword->setVisible(false);
20
21 ui->rbPassword->setText(tr("Input %1").arg(szTitle));
22}
23
24CDlgInputPassword::~CDlgInputPassword()
25{
26 delete ui;
27}
28
29void CDlgInputPassword::on_pbNo_clicked()
30{
31 reject();
32}
33
34void CDlgInputPassword::on_pbYes_clicked()
35{
36 accept();
37}
38
39int CDlgInputPassword::GetValue(InputType &t, QString &password)
40{
41 if(ui->rbKey->isChecked()) t = Encrypt;
42 if(ui->rbPassword->isChecked()) t = Password;
43 password = ui->lePassword->text();
44 return 0;
45}
46
47void CDlgInputPassword::on_pbShow_clicked()
48{
49 switch(ui->lePassword->echoMode())
50 {
51 case QLineEdit::Password:
52 ui->lePassword->setEchoMode(QLineEdit::Normal);
53 ui->pbShow->setIcon(QIcon::fromTheme("eye-off"));
54 break;
55 case QLineEdit::Normal:
56 ui->lePassword->setEchoMode(QLineEdit::Password);
57 ui->pbShow->setIcon(QIcon::fromTheme("eye-on"));
58 break;
59 default:
60 break;
61 }
62}