You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.9 KiB
75 lines
1.9 KiB
#ifndef LOGINWIDGET_H
|
|
#define LOGINWIDGET_H
|
|
|
|
#include "base_widget.h"
|
|
#include <QWidget>
|
|
#include <QStackedWidget>
|
|
#include <QLineEdit>
|
|
#include <QPushButton>
|
|
#include <QLabel>
|
|
#include "../shared/backend_interface.h"
|
|
|
|
class LoginWidget : public BaseWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
//禁止隐式类型转换
|
|
explicit LoginWidget(exam_system::BackendInterface* backend, QWidget* parent = nullptr);
|
|
|
|
//清空输入
|
|
void clearInputs();
|
|
|
|
signals:
|
|
// 登录成功信号
|
|
void loginSuccess(const QString& userName);
|
|
// 注册成功信号
|
|
void registerSuccess(const QString& userName);
|
|
|
|
private slots:
|
|
// 登录按钮点击
|
|
void onLoginClicked();
|
|
// 显示注册页面
|
|
void showRegisterPage();
|
|
// 显示登录页面
|
|
void showLoginPage();
|
|
// 注册按钮点击
|
|
void onRegisterClicked();
|
|
// 发送验证码按钮点击
|
|
void onSendCodeClicked();
|
|
|
|
private:
|
|
// 初始化界面
|
|
void setupUI() override;
|
|
// 设置登录页面
|
|
void setupLoginPage();
|
|
// 设置注册页面
|
|
void setupRegisterPage();
|
|
// 验证密码格式
|
|
bool validatePassword(const QString &password);
|
|
void onCountdownTimeout();
|
|
// 登录页面组件
|
|
QWidget *loginPage;
|
|
QLineEdit *loginUserNameEdit;
|
|
QLineEdit *loginPasswordEdit;
|
|
QPushButton *loginBtn;
|
|
QPushButton *toRegisterBtn;
|
|
|
|
// 注册页面组件
|
|
QWidget *registerPage;
|
|
QLineEdit *registerEmailEdit;
|
|
QLineEdit *registerUserNameEdit;
|
|
QLineEdit *codeEdit;
|
|
QLineEdit *registerPasswordEdit;
|
|
QLineEdit *confirmPasswordEdit;
|
|
QPushButton *sendCodeBtn;
|
|
QPushButton *registerBtn;
|
|
QPushButton *toLoginBtn;
|
|
|
|
//BackendInterface* backend;
|
|
QStackedWidget *stackedWidget; // 页面堆栈
|
|
QTimer *countdownTimer;
|
|
int countdown_seconds_;
|
|
};
|
|
|
|
#endif |