-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresetpassword.cpp
64 lines (56 loc) · 2.15 KB
/
resetpassword.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
#include "resetpassword.h"
#include "ui_resetpassword.h"
#include <QDebug> // Include for debugging
#include <QCloseEvent>
// =========================
// Constructor & Destructor
// =========================
resetPassword::resetPassword(QWidget *parent)
: QDialog(parent), ui(new Ui::resetPassword)
{
ui->setupUi(this);
QPalette palette_loginErr = ui->errorLabel->palette();
palette_loginErr.setColor(QPalette::WindowText, Qt::red); // Set the error label text color to red
ui->errorLabel->setPalette(palette_loginErr);
ui->errorLabel->hide(); // Hide the error label initially
setWindowTitle("Falkenberg's Password Manager");
}
resetPassword::~resetPassword()
{
delete ui;
}
void resetPassword::closeEvent(QCloseEvent *event)
{
QCoreApplication::quit(); // Quit the entire application
event->accept(); // Accept the event, allowing the window to close
}
// ==================
// Slot Implementations
// ==================
// Handles the cancel button click event
void resetPassword::on_cancelButton_clicked()
{
emit resetCanceled(); // Emit the signal before clearing the entries
ui->passEntryOne->clear(); // Clear the first password entry
ui->passEntryTwo->clear(); // Clear the second password entry
this->reject(); // Close the dialog using reject
}
// Handles the confirm button click event
void resetPassword::on_confirmButton_clicked()
{
QString passOne = ui->passEntryOne->text();
QString passTwo = ui->passEntryTwo->text();
if (passOne.length() < 8) {
ui->errorLabel->setText("Password Too Short (8 characters or more)");
ui->errorLabel->show(); // Show the error label with the appropriate message
}
else if (passOne != passTwo) {
ui->errorLabel->setText("Passwords Don't Match");
ui->errorLabel->show(); // Show the error label with the appropriate message
} else {
emit passwordUpdated(passOne); // Emit the new password if validation passes
ui->passEntryOne->clear(); // Clear the first password entry
ui->passEntryTwo->clear(); // Clear the second password entry
this->accept(); // Close the dialog using accept
}
}