2018-11-04 11:26:20 +01:00
|
|
|
|
#ifndef PASSWORDPROMPTDIALOG_H
|
|
|
|
|
|
#define PASSWORDPROMPTDIALOG_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QDialog>
|
2018-11-11 12:30:53 +01:00
|
|
|
|
#include <optional>
|
2018-11-04 11:26:20 +01:00
|
|
|
|
|
|
|
|
|
|
class QCheckBox;
|
2018-11-15 19:24:29 +01:00
|
|
|
|
class QComboBox;
|
2018-11-08 21:50:49 +01:00
|
|
|
|
class QDialogButtonBox;
|
2018-11-04 11:26:20 +01:00
|
|
|
|
class QLabel;
|
|
|
|
|
|
class QLineEdit;
|
|
|
|
|
|
|
|
|
|
|
|
class PasswordPromptDialog : public QDialog
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
2018-11-08 21:50:49 +01:00
|
|
|
|
enum Flag {
|
|
|
|
|
|
ConfirmPassword = 1,
|
2018-11-15 19:24:29 +01:00
|
|
|
|
SaveOption = 2,
|
|
|
|
|
|
RememberPassword = 4
|
2018-11-08 21:50:49 +01:00
|
|
|
|
};
|
2018-11-04 11:26:20 +01:00
|
|
|
|
|
2018-11-08 21:50:49 +01:00
|
|
|
|
Q_DECLARE_FLAGS(Flags, Flag)
|
|
|
|
|
|
//Q_FLAG(Flags)
|
|
|
|
|
|
|
|
|
|
|
|
explicit PasswordPromptDialog(Flags flags, QWidget *parent = nullptr);
|
|
|
|
|
|
|
2018-11-11 12:30:53 +01:00
|
|
|
|
|
|
|
|
|
|
PasswordPromptDialog& setCaption(const std::optional<QString> &caption);
|
|
|
|
|
|
PasswordPromptDialog& setDescription(const QString &description);
|
|
|
|
|
|
/// Checks the save checkbox when save is true, this call is ignored when the checkbox does not exist
|
|
|
|
|
|
PasswordPromptDialog& setSaveChecked(bool save);
|
2018-11-04 11:26:20 +01:00
|
|
|
|
|
|
|
|
|
|
QString password() const;
|
2018-11-08 21:50:49 +01:00
|
|
|
|
bool saveChecked() const;
|
2018-11-15 19:24:29 +01:00
|
|
|
|
/// Returns how long the user wants the password remembered
|
|
|
|
|
|
///
|
|
|
|
|
|
/// \return time to remember password in minutes, 0= do not remember, -1= until termination
|
|
|
|
|
|
int remember() const;
|
2018-11-04 11:26:20 +01:00
|
|
|
|
private:
|
2018-11-11 12:30:53 +01:00
|
|
|
|
static const char* translateContext;
|
|
|
|
|
|
|
2018-11-08 21:50:49 +01:00
|
|
|
|
Flags m_Flags;
|
2018-11-11 12:30:53 +01:00
|
|
|
|
QLabel *m_descriptionLabel = nullptr;
|
2018-11-08 21:50:49 +01:00
|
|
|
|
QLabel *m_passwordLabel[2] = { nullptr, nullptr };
|
|
|
|
|
|
QLineEdit *m_passwordInput[2] = { nullptr, nullptr };
|
2018-11-04 11:26:20 +01:00
|
|
|
|
QCheckBox *m_saveCheck = nullptr;
|
2018-11-15 19:24:29 +01:00
|
|
|
|
QLabel *m_rememberLabel = nullptr;
|
|
|
|
|
|
QComboBox *m_rememberChoices = nullptr;
|
2018-11-08 21:50:49 +01:00
|
|
|
|
QDialogButtonBox *m_DialogButtons = nullptr;
|
2018-11-04 11:26:20 +01:00
|
|
|
|
|
2018-11-11 12:30:53 +01:00
|
|
|
|
std::optional<QString> m_customCaption;
|
|
|
|
|
|
|
2018-11-04 11:26:20 +01:00
|
|
|
|
void retranslateUi();
|
2018-11-08 21:50:49 +01:00
|
|
|
|
void updateOkEnabled();
|
2018-11-11 12:30:53 +01:00
|
|
|
|
void UpdateCaption();
|
2018-11-04 11:26:20 +01:00
|
|
|
|
|
|
|
|
|
|
private slots:
|
2018-11-08 21:50:49 +01:00
|
|
|
|
void passwordChanged(const QString &text);
|
2018-11-04 11:26:20 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // PASSWORDPROMPTDIALOG_H
|