diff options
author | Loren Burkholder <computersemiexpert@outlook.com> | 2023-06-28 17:00:34 -0400 |
---|---|---|
committer | Loren Burkholder <computersemiexpert@outlook.com> | 2023-07-06 08:35:37 -0400 |
commit | fedc178827c5648b0ccbdd2cd08dcebc920ac416 (patch) | |
tree | 7c6c59b60899d8c7a321bea8fe44c7d04f79040f /src/ui | |
parent | Remove unneeded forward declaration (diff) | |
download | nheko-fedc178827c5648b0ccbdd2cd08dcebc920ac416.tar.xz |
Port the reCAPTCHA dialog to QML
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/UIA.cpp | 28 | ||||
-rw-r--r-- | src/ui/UIA.h | 5 |
2 files changed, 14 insertions, 19 deletions
diff --git a/src/ui/UIA.cpp b/src/ui/UIA.cpp index 2b6b059a..ba35df9b 100644 --- a/src/ui/UIA.cpp +++ b/src/ui/UIA.cpp @@ -14,12 +14,12 @@ #include "Logging.h" #include "MatrixClient.h" #include "dialogs/FallbackAuth.h" -#include "dialogs/ReCaptcha.h" +#include "ReCaptcha.h" UIA * UIA::instance() { - static UIA uia; + static UIA uia{nullptr}; return &uia; } @@ -99,24 +99,16 @@ UIA::genericHandler(QString context) } else if (current_stage == mtx::user_interactive::auth_types::msisdn) { emit phoneNumber(); } else if (current_stage == mtx::user_interactive::auth_types::recaptcha) { - auto captchaDialog = - new dialogs::ReCaptcha(QString::fromStdString(u.session), nullptr); - captchaDialog->setWindowTitle(context); - - connect( - captchaDialog, &dialogs::ReCaptcha::confirmation, this, [captchaDialog, h, u]() { - captchaDialog->close(); - captchaDialog->deleteLater(); - h.next(mtx::user_interactive::Auth{u.session, - mtx::user_interactive::auth::Fallback{}}); - }); - - connect(captchaDialog, &dialogs::ReCaptcha::cancel, this, [this]() { + auto captcha = new ReCaptcha(QString::fromStdString(u.session), context, nullptr); + QQmlEngine::setObjectOwnership(captcha, QQmlEngine::JavaScriptOwnership); + connect(captcha, &ReCaptcha::confirmation, this, [h, u]() { + h.next(mtx::user_interactive::Auth{u.session, + mtx::user_interactive::auth::Fallback{}}); + }); + connect(captcha, &ReCaptcha::cancelled, this, [this]() { emit error(tr("Registration aborted")); }); - - QTimer::singleShot(0, this, [captchaDialog]() { captchaDialog->show(); }); - + emit reCaptcha(captcha); } else if (current_stage == mtx::user_interactive::auth_types::dummy) { h.next( mtx::user_interactive::Auth{u.session, mtx::user_interactive::auth::Dummy{}}); diff --git a/src/ui/UIA.h b/src/ui/UIA.h index 414cb804..5b5eb9f4 100644 --- a/src/ui/UIA.h +++ b/src/ui/UIA.h @@ -9,6 +9,8 @@ #include <mtxclient/http/client.hpp> +#include "ReCaptcha.h" + class UIA final : public QObject { Q_OBJECT @@ -39,7 +41,7 @@ public: return instance(); } - UIA(QObject *parent = nullptr) + UIA(QObject *parent) : QObject(parent) { } @@ -59,6 +61,7 @@ signals: void password(); void email(); void phoneNumber(); + void reCaptcha(ReCaptcha *recaptcha); void confirm3pidToken(); void prompt3pidToken(); |