| 1 |
#ifndef DIALOGS_ENTERPASSWORDDIALOG_H |
| 2 |
#define DIALOGS_ENTERPASSWORDDIALOG_H |
| 3 |
|
| 4 |
#include "../global.h" |
| 5 |
|
| 6 |
#include <QDialog> |
| 7 |
|
| 8 |
#include <memory> |
| 9 |
|
| 10 |
namespace QtUtilities { |
| 11 |
|
| 12 |
namespace Ui { |
| 13 |
class 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 |
|
| 27 |
public: |
| 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 |
|
| 44 |
protected: |
| 45 |
bool event(QEvent *event) override; |
| 46 |
bool eventFilter(QObject *sender, QEvent *event) override; |
| 47 |
|
| 48 |
private Q_SLOTS: |
| 49 |
void updateShowPassword(); |
| 50 |
void confirm(); |
| 51 |
void abort(); |
| 52 |
|
| 53 |
private: |
| 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 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
inline const QString &EnterPasswordDialog::userName() const |
| 65 |
{ |
| 66 |
return m_userName; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
inline const QString &EnterPasswordDialog::password() const |
| 73 |
{ |
| 74 |
return m_password; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
inline const QString &EnterPasswordDialog::instruction() const |
| 88 |
{ |
| 89 |
return m_instruction; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
inline void EnterPasswordDialog::abort() |
| 98 |
{ |
| 99 |
m_password.clear(); |
| 100 |
done(QDialog::Rejected); |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
#endif |