Qt Utilities: enterpassworddialog/enterpassworddialog.h Source File

Qt Utilities 6.20.0 Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models

Loading...
Searching...
No Matches
enterpassworddialog.h
Go to the documentation of this file.
1#ifndef DIALOGS_ENTERPASSWORDDIALOG_H
2#define DIALOGS_ENTERPASSWORDDIALOG_H
3
4#include "../global.h"
5
6#include <QDialog>
7
8#include <memory>
9
10namespace QtUtilities {
11
12namespace Ui {
13class EnterPasswordDialog;
14}
15
16 class QT_UTILITIES_EXPORT EnterPasswordDialog : public QDialog {
17 Q_OBJECT
18 Q_PROPERTY(QString userName READ userName)
19 Q_PROPERTY(QString password READ password)
20 Q_PROPERTY(QString description READ description WRITE setDescription)
21 Q_PROPERTY(bool promtForUserName READ promtForUserName WRITE setPromptForUserName)
22 Q_PROPERTY(bool isVerificationRequired READ isVerificationRequired WRITE setVerificationRequired)
23 Q_PROPERTY(bool isPasswordRequired READ isPasswordRequired WRITE setPasswordRequired)
24 Q_PROPERTY(QString instruction READ instruction WRITE setInstruction)
25 Q_PROPERTY(bool isCapslockPressed READ isCapslockPressed)
26
27public:
28 explicit EnterPasswordDialog(QWidget *parent = nullptr);
29 ~EnterPasswordDialog() override;
30 const QString &userName() const;
31 const QString &password() const;
32 QString description() const;
33 void setDescription(const QString &description = QString());
34 bool promtForUserName() const;
35 void setPromptForUserName(bool prompt);
36 bool isVerificationRequired() const;
37 void setVerificationRequired(bool value);
38 bool isPasswordRequired() const;
39 void setPasswordRequired(bool value);
40 const QString &instruction() const;
41 void setInstruction(const QString &value);
42 static bool isCapslockPressed();
43
44protected:
45 bool event(QEvent *event) override;
46 bool eventFilter(QObject *sender, QEvent *event) override;
47
48private Q_SLOTS:
49 void updateShowPassword();
50 void confirm();
51 void abort();
52
53private:
54 std::unique_ptr<Ui::EnterPasswordDialog> m_ui;
55 QString m_userName;
56 QString m_password;
57 QString m_instruction;
58 bool m_capslockPressed;
59};
60
64inline const QString &EnterPasswordDialog::userName() const
65{
66 return m_userName;
67}
68
72 inline const QString &EnterPasswordDialog::password() const
73{
74 return m_password;
75}
76
87 inline const QString &EnterPasswordDialog::instruction() const
88{
89 return m_instruction;
90}
91
97inline void EnterPasswordDialog::abort()
98{
99 m_password.clear();
100 done(QDialog::Rejected);
101}
102} // namespace QtUtilities
103
104#endif // DIALOGS_ENTERPASSWORDDIALOG_H
QtUtilities::EnterPasswordDialog::EnterPasswordDialog
EnterPasswordDialog(QWidget *parent=nullptr)
Constructs a password dialog.
Definition enterpassworddialog.cpp:37
QtUtilities::EnterPasswordDialog::isCapslockPressed
bool isCapslockPressed
Returns an indication whether the capslock key is pressed using platform specific functions.
Definition enterpassworddialog.h:25
QtUtilities::EnterPasswordDialog::isVerificationRequired
bool isVerificationRequired
Definition enterpassworddialog.h:22
QtUtilities::EnterPasswordDialog::eventFilter
bool eventFilter(QObject *sender, QEvent *event) override
Internal method to notice when the capslock key is pressed by the user.
Definition enterpassworddialog.cpp:234
QtUtilities::EnterPasswordDialog::setPromptForUserName
void setPromptForUserName(bool prompt)
Sets whethere the dialog prompts for a user name as well.
Definition enterpassworddialog.cpp:114
QtUtilities::EnterPasswordDialog::setDescription
void setDescription(const QString &description=QString())
Sets the description.
Definition enterpassworddialog.cpp:91
QtUtilities::EnterPasswordDialog::setVerificationRequired
void setVerificationRequired(bool value)
Sets whether a verification (password has to be entered twice) is required.
Definition enterpassworddialog.cpp:180
QtUtilities::EnterPasswordDialog::setInstruction
void setInstruction(const QString &value)
Sets the instruction text.
Definition enterpassworddialog.cpp:194
QtUtilities::EnterPasswordDialog::userName
QString userName
Definition enterpassworddialog.h:18
QtUtilities::EnterPasswordDialog::setPasswordRequired
void setPasswordRequired(bool value)
Sets whether the user is force to enter a password.
Definition enterpassworddialog.cpp:154
QtUtilities::EnterPasswordDialog::description
QString description
Definition enterpassworddialog.h:20
QtUtilities::EnterPasswordDialog::promtForUserName
bool promtForUserName
Definition enterpassworddialog.h:21
QtUtilities::EnterPasswordDialog::isPasswordRequired
bool isPasswordRequired
Definition enterpassworddialog.h:23
QtUtilities::EnterPasswordDialog::event
bool event(QEvent *event) override
Definition enterpassworddialog.cpp:205
QtUtilities::EnterPasswordDialog::instruction
QString instruction
Definition enterpassworddialog.h:24
QtUtilities::EnterPasswordDialog::password
QString password
Definition enterpassworddialog.h:19
global.h
QT_UTILITIES_EXPORT
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14
QtUtilities::Ui
Definition aboutdialog.h:14
QtUtilities
!
Definition trylocker.h:8