#ifndef LOGINWIDGET_H
#define LOGINWIDGET_H

#include <QWidget>

class QGridLayout;
class QVBoxLayout;
class QHBoxLayout;
class QLabel;
class QComboBox;
class QLineEdit;
class QPushButton;
class QCheckBox;
class QMouseEvent;
class QSpacerItem;
class WordArtWidget;
class LoginWaitWidget;

/**
* @brief 角色类型
*  员工, 工程师，主管
**/
enum RoleType {Staff, Engineer, Leader};

class LoginWidget : public QWidget
{
    Q_OBJECT
public:
    explicit LoginWidget(QWidget* parent = nullptr);
    ~LoginWidget();

    /**
    * @brief 退出登录
    **/
    void quitLogin();

    void show();

    void setBackgroundImage(const QString& path);

    bool isLogin();
signals:
    /**
    * @brief 返回信号
    *  点击返回按钮，触发返回信号
    **/
    void signalReturn();

    void loggedIn();

protected:
    void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;

    void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;

private:
    void initialize();
    void createConnections();

private slots:
    /**
    * @brief 显示填写的密码
    **/
    void slotShowPassword();
    /**
    * @brief 隐藏填写的密码
    **/
    void slotHidePassword();

    /**
    * @brief 登录
    **/
    void slotLogin();

    /**
    * @brief 取消登录
    **/
    void slotCancel();


private:
    QVBoxLayout* m_pMainVLayout;

    // 登录窗口
    QWidget* m_pLoginWidget;
    QVBoxLayout* m_pLoginVLayout;

    // 登录窗口标题
    WordArtWidget* m_pTitleWidget;

    QHBoxLayout* m_pRememberHLayout;
    QCheckBox* m_pRememberAccountButton;  // 记住ID
    QCheckBox* m_pRememberPasswordButton; // 记住密码


    QWidget* m_pAccountWidget;
    //QVBoxLayout* m_pAccountVLayout;
    QGridLayout* m_pAccoutGLayout;

    QLabel* mRoleLabel;
    QComboBox* mRoleComboBox;

    QHBoxLayout* m_pAccountHLayout;
    QLabel* m_pAccountLabel;
    QComboBox* m_pAccountComboBox;      // ID

    QHBoxLayout* m_pPasswordHLayout;
    QLabel* m_pPasswordLabel;
    QLineEdit* m_pPasswordLineEdit;     // 密码

    QHBoxLayout* m_pButtonHLayout;
    QPushButton* m_pLoginButton;        //登录按钮
    QPushButton* m_pReturnButton;       // 返回按钮

    bool m_bMove;
    QPoint m_spanPoint;
    bool m_bFixed;
    QString mBackImagePath;
    QPixmap mBackPixmap;

    bool mLogin;
};

#endif // LOGINWIDGET_H
