diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index 6337928..b2876f8 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -102,7 +102,7 @@ public: * The launcher will still warn the user about any possible errors, however the call site will need to check the * result to see whether they need to "reset" or show a failed state or not. */ - Q_INVOKABLE void autoLogin(Profile *profile); + Q_INVOKABLE bool autoLogin(Profile *profile); /* * Launches the game using the provided authentication. diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index 3f1de92..3874c45 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -448,23 +448,24 @@ void LauncherCore::login(Profile *profile, const QString &username, const QStrin beginLogin(*loginInformation); } -void LauncherCore::autoLogin(Profile *profile) +bool LauncherCore::autoLogin(Profile *profile) { QString otp; if (profile->account()->useOTP()) { if (!profile->account()->rememberOTP()) { Q_EMIT loginError("This account does not have an OTP secret set, but requires it for login."); - return; + return false; } otp = profile->account()->getOTP(); if (otp.isEmpty()) { Q_EMIT loginError("Failed to generate OTP, review the stored secret."); - return; + return false; } } login(profile, profile->account()->name(), profile->account()->getPassword(), otp); + return true; } GameInstaller *LauncherCore::createInstaller(Profile *profile) diff --git a/launcher/ui/Pages/AutoLoginPage.qml b/launcher/ui/Pages/AutoLoginPage.qml index 3b09eb1..19535a7 100644 --- a/launcher/ui/Pages/AutoLoginPage.qml +++ b/launcher/ui/Pages/AutoLoginPage.qml @@ -13,7 +13,9 @@ Kirigami.Page { title: i18n("Auto Login") - Kirigami.LoadingPlaceholder { + globalToolBarStyle: Kirigami.ApplicationHeaderStyle.None + + Kirigami.PlaceholderMessage { id: placeholderMessage anchors.centerIn: parent @@ -38,8 +40,29 @@ Kirigami.Page { running: true onTriggered: { autoLoginTimer.stop(); - LauncherCore.autoLogin(LauncherCore.autoLoginProfile); - pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage")); + if (LauncherCore.autoLogin(LauncherCore.autoLoginProfile)) { + pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage")); + } + } + } + + Kirigami.PromptDialog { + id: errorDialog + title: i18n("Login Error") + + showCloseButton: false + standardButtons: Kirigami.Dialog.Ok + + onAccepted: applicationWindow().cancelAutoLogin() + onRejected: applicationWindow().cancelAutoLogin() + } + + Connections { + target: LauncherCore + + function onLoginError(message) { + errorDialog.subtitle = message + errorDialog.open() } } }