#ifndef DIALOGCONTROLPASSWORD_H #define DIALOGCONTROLPASSWORD_H #include #include #include #include #include class QLabel; class QKeyEvent; namespace Ui { class DialogControlPassword; } class DialogControlPassword : public QDialog { Q_OBJECT public: static const int kPasswordLength = 6; explicit DialogControlPassword(QWidget* parent = nullptr); ~DialogControlPassword() override; void SetTitle(const QString& title); QString Password() const; void SetError(const QString& text); void SetPasswordChecker(const std::function& checker); protected: void showEvent(QShowEvent* event) override; void keyPressEvent(QKeyEvent* event) override; private slots: void on_btnOK_clicked(); void on_btnCancel_clicked(); private: void ApplyUiFont(); void BuildDigitBoxes(); void BuildKeypad(); void AppendDigit(QChar digit); void RemoveLastDigit(); void ClearPassword(); void RefreshDigits(); void UpdateOkEnabled(); void TryAccept(); Ui::DialogControlPassword* ui = nullptr; std::function m_passwordChecker; QString m_password; QVector m_digitLabels; }; #endif // DIALOGCONTROLPASSWORD_H