Qt Utilities 6.14.3
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
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
72inline const QString &EnterPasswordDialog::password() const
73{
74 return m_password;
75}
76
87inline 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
The EnterPasswordDialog class provides a simple dialog to ask the user for a password.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14