Limo
A simple mod manager
Loading...
Searching...
No Matches
passwordfield.h
Go to the documentation of this file.
1
5#pragma once
6
8#include <QPushButton>
9#include <QWidget>
10
11
17class PasswordField : public QWidget
18{
19 Q_OBJECT
20public:
22 enum Role
23 {
28 };
29
34 explicit PasswordField(QWidget* parent = nullptr);
35
40 QString getPassword() const;
51 void setPartnerField(PasswordField* partner, Role partner_role);
52
53private:
57 QPushButton* view_button_;
59 const QIcon show_icon = QIcon::fromTheme("view-visible");
61 const QIcon hide_icon = QIcon::fromTheme("view-hidden");
67 bool is_valid_ = true;
68
71
72public slots:
77 void onPartnerFieldChanged(QString new_password);
78
79private slots:
84 void onPasswordEdited(QString new_password);
87
88signals:
93 void passwordEdited(QString new_password);
98 void passwordValidityChanged(bool is_valid);
99};
Widget used to enter passwords. Contains a line field for input and a button to show/ hide the passwo...
Definition passwordfield.h:18
QPushButton * view_button_
Button used to show/ hide the password.
Definition passwordfield.h:57
Role
Role of this field.
Definition passwordfield.h:23
@ main
This is the main PasswordField.
Definition passwordfield.h:25
@ repeat
This PasswordField is meant for repetition checking.
Definition passwordfield.h:27
void passwordEdited(QString new_password)
Signals that the current password has been edited by the user.
void onPasswordEdited(QString new_password)
Updates the visual feedback for matching passwords.
Definition passwordfield.cpp:75
Role role_
Role if this field.
Definition passwordfield.h:65
void updateValidationStatus()
Updates the is_valid_ flag to be false if role_ == repeat and the passwords mismatch.
Definition passwordfield.cpp:55
const QIcon show_icon
Icon used to indicate that the password is to be shown.
Definition passwordfield.h:59
bool is_valid_
Always true if role_ == main. Else only true if both passwords match.
Definition passwordfield.h:67
void passwordValidityChanged(bool is_valid)
Sent when the is_valid_ status of this field changes.
void onPartnerFieldChanged(QString new_password)
Updates the visual feedback for matching passwords.
Definition passwordfield.cpp:68
PasswordField * partner_
Partner PasswordField.
Definition passwordfield.h:63
void onViewButtonPressed()
Toggles password visibility.
Definition passwordfield.cpp:81
ValidatingLineEdit * password_line_edit_
Used for input. Gives visual feedback is this has a repeat role and the passwords dont match.
Definition passwordfield.h:55
const QIcon hide_icon
Icon used to indicate that the password is to be hidden.
Definition passwordfield.h:61
ValidatingLineEdit * getPasswordLineEdit() const
Returns the ValidatingLineEdit used for input.
Definition passwordfield.cpp:29
PasswordField(QWidget *parent=nullptr)
Initializes the UI.
Definition passwordfield.cpp:6
QString getPassword() const
Returns the password currently in the password field..
Definition passwordfield.cpp:24
void setPartnerField(PasswordField *partner, Role partner_role)
Sets a partner PasswordField for repetition checking.
Definition passwordfield.cpp:34
A line edit which automatically validates its input and shows a visual indicator for invalid inputs.
Definition validatinglineedit.h:15
Header for the ValidatingLineEdit class.