-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmasterpasswordform.cpp
More file actions
71 lines (66 loc) · 1.79 KB
/
masterpasswordform.cpp
File metadata and controls
71 lines (66 loc) · 1.79 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
62
63
64
65
66
67
68
69
70
71
#include "masterpasswordform.h"
#include "ui_masterpasswordform.h"
#include"databasesettingsform.h"
#include <QMessageBox>
MasterPasswordForm::MasterPasswordForm(QWidget *parent) :
QDialog(parent),
ui(new Ui::MasterPasswordForm),passwordVisible(false)
{
ui->setupUi(this);
}
MasterPasswordForm::~MasterPasswordForm()
{
delete ui;
mainForm=0;
delete mainForm;
}
HomeScreen* MasterPasswordForm::getMainFormReference()
{
return mainForm;
}
void MasterPasswordForm::setMainFormReference(HomeScreen *main)
{
mainForm=main;
}
void MasterPasswordForm::on_buttonBox_Response_accepted()
{
QString masterKey=ui->lineEdit_masterPass->text(),repeatKey=ui->lineEdit_repeatPass->text();
//validation
if(masterKey.isEmpty())
{
QMessageBox::warning(this,tr("Master Key"),tr("Please enter the master password..."));
return;
}
if(!passwordVisible)
{
if(masterKey!=repeatKey)
{
QMessageBox::warning(this,tr("Master Key"),"Make sure both passwords match...");
return;
}
}
DatabaseSettingsForm settings;//open form for entering the new database's details
settings.setMasterKey(masterKey);
settings.setMainFormReference(getMainFormReference());
this->hide();
settings.exec();
}
void MasterPasswordForm::on_buttonBox_Response_rejected()
{
this->close();
}
void MasterPasswordForm::on_pushButton_passwordView_clicked()
{
if(passwordVisible)
{
ui->lineEdit_masterPass->setEchoMode(QLineEdit::EchoMode::Password);
ui->lineEdit_repeatPass->setEnabled(true);
passwordVisible=false;
}
else
{
ui->lineEdit_masterPass->setEchoMode(QLineEdit::EchoMode::Normal);
ui->lineEdit_repeatPass->setEnabled(false);
passwordVisible=true;
}
}