mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-31 03:45:38 +00:00
Qt/AchievementLoginDialog: Make login fully asynchronous
This commit is contained in:
parent
a7017783e4
commit
2e86b65bf9
|
@ -20,15 +20,20 @@ void AchievementLoginDialog::loginClicked()
|
|||
// TODO: Make cancellable.
|
||||
m_ui.status->setText(tr("Logging in..."));
|
||||
enableUI(false);
|
||||
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
bool result;
|
||||
QtHostInterface::GetInstance()->executeOnEmulationThread(
|
||||
[username, password, &result]() {
|
||||
result = Cheevos::Login(username.toStdString().c_str(), password.toStdString().c_str());
|
||||
},
|
||||
true);
|
||||
QtHostInterface::GetInstance()->executeOnEmulationThread([this, username, password]() {
|
||||
const bool result = Cheevos::Login(username.toStdString().c_str(), password.toStdString().c_str());
|
||||
QMetaObject::invokeMethod(this, "processLoginResult", Qt::QueuedConnection, Q_ARG(bool, result));
|
||||
});
|
||||
}
|
||||
|
||||
void AchievementLoginDialog::cancelClicked()
|
||||
{
|
||||
done(1);
|
||||
}
|
||||
|
||||
void AchievementLoginDialog::processLoginResult(bool result)
|
||||
{
|
||||
if (!result)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Login Error"),
|
||||
|
@ -41,11 +46,6 @@ void AchievementLoginDialog::loginClicked()
|
|||
done(0);
|
||||
}
|
||||
|
||||
void AchievementLoginDialog::cancelClicked()
|
||||
{
|
||||
done(1);
|
||||
}
|
||||
|
||||
void AchievementLoginDialog::connectUi()
|
||||
{
|
||||
connect(m_ui.login, &QPushButton::clicked, this, &AchievementLoginDialog::loginClicked);
|
||||
|
|
|
@ -13,6 +13,7 @@ public:
|
|||
private Q_SLOTS:
|
||||
void loginClicked();
|
||||
void cancelClicked();
|
||||
void processLoginResult(bool result);
|
||||
|
||||
private:
|
||||
void connectUi();
|
||||
|
|
Loading…
Reference in a new issue