-
Notifications
You must be signed in to change notification settings - Fork 0
/
editpassworddata.cpp
62 lines (55 loc) · 1.9 KB
/
editpassworddata.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
#include "editpassworddata.h"
#include "ui_editpassworddata.h"
#include <QStandardPaths>
#include "retrievePassword.h"
#include "ui_retrievepassword.h"
#include "CryptoUtils.h"
#include "QPushButton"
#include <QFile>
#include <QDir>
#include <QJsonDocument>
#include <QJsonObject>
#include <QTableWidgetItem>
#include <QStandardPaths>
#include "mainwindow.h" // Include this to access globalCipherKey
#include <QMessageBox>
// ====================
// editPasswordData Constructor
// ====================
editPasswordData::editPasswordData(QWidget *parent, QString passId, QString dateStored, QString password, QString username, QString thoughts)
: QDialog(parent)
, ui(new Ui::editPasswordData)
{
ui->setupUi(this);
ui->passwordIdEdit->setText(passId);
ui->passwordEdit->setText(password);
ui->usernameEdit->setText(username);
ui->thoughtsEdit->setText(thoughts);
setWindowTitle("Falkenberg's Password Manager");
}
// ====================
// editPasswordData Destructor
// ====================
editPasswordData::~editPasswordData()
{
delete ui;
}
// ====================
// Private Slots
// ====================
// Handle back button click
void editPasswordData::on_backButton_clicked()
{
this->deleteLater();
}
// Handle save button click
void editPasswordData::on_saveButton_clicked()
{
QString newPassId = ui->passwordIdEdit->toPlainText(); // Collect new password ID
QString newPassword = ui->passwordEdit->toPlainText(); // Collect new password
QString newUsername = ui->usernameEdit->toPlainText(); // Collect new username
QString newThoughts = ui->thoughtsEdit->toPlainText(); // Collect new thoughts
QString newDateStored = QDate::currentDate().toString(Qt::ISODate); // Collect new date stored
emit overwriteData(newPassId, newDateStored, newPassword, newUsername, newThoughts); // Emit signal to overwrite data
this->close(); // Close the dialog
}