Skip to content

Commit

Permalink
登录界面与主界面交互
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Porter committed Jul 6, 2024
1 parent 5d326b1 commit 2141af0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions loginwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void LoginWindow::on_loadBtn_clicked()
User loginuser(ui->account->text(),ui->password->text());
if(loginuser.login()){
QMessageBox::information(this, "成功","登录成功");
emit on_login_complete(loginuser);
this->close();
}
else
Expand Down
2 changes: 1 addition & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ MainWindow::MainWindow(QWidget *parent)
});
*/
qDebug() << ElaEventBus::getInstance()->getRegisteredEventsName();
QObject::connect(loginWindow, &LoginWindow::on_login_complete, mainWindow, &MainWindow::onUserLoggedIn);
QObject::connect(login, &LoginWindow::on_login_complete, this, &MainWindow::onUserLoggedIn);
// 拦截默认关闭事件
this->setIsDefaultClosed(false);
connect(this, &MainWindow::closeButtonClicked, this, &MainWindow::onCloseButtonClicked);
Expand Down
11 changes: 11 additions & 0 deletions user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ User::User(const QString &account, const QString &password, QObject *parent)
apiRequest->setBaseUrl("https://syncapi.snakekiss.com");
}

User::User(const User &user)
{
username=user.username;
account=user.account;
hashedPassword=user.hashedPassword;
isLogin=user.isLogin;
apiRequest=new ApiRequest(this);
apiRequest->setBaseUrl("https://syncapi.snakekiss.com");
}


bool User::enroll()
{
QString postData
Expand Down
1 change: 1 addition & 0 deletions user.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class User : public QObject
User(const QString &account,
const QString &password,
QObject *parent = nullptr);
User(const User &user);
bool enroll(); //执行post请求,实现注册功能
bool login(); //执行post请求,实现登录功能
bool forgetPassword(); //执行post请求,实现找回密码功能
Expand Down

0 comments on commit 2141af0

Please sign in to comment.