diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-08-14 02:27:01 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-08-14 02:27:01 +0200 |
commit | 0adb572a07d13a35bdb378ba024655de6a9967b3 (patch) | |
tree | 9c2d1b4b0e45669f181841adc584017549e86648 /application/LaunchInteraction.cpp | |
parent | 8ed10c5b8142243481305c5cba8318eed2f4a120 (diff) | |
download | MultiMC-0adb572a07d13a35bdb378ba024655de6a9967b3.tar MultiMC-0adb572a07d13a35bdb378ba024655de6a9967b3.tar.gz MultiMC-0adb572a07d13a35bdb378ba024655de6a9967b3.tar.lz MultiMC-0adb572a07d13a35bdb378ba024655de6a9967b3.tar.xz MultiMC-0adb572a07d13a35bdb378ba024655de6a9967b3.zip |
NOISSUE improve account UI
Diffstat (limited to 'application/LaunchInteraction.cpp')
-rw-r--r-- | application/LaunchInteraction.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/application/LaunchInteraction.cpp b/application/LaunchInteraction.cpp index 070c8249..c7ef942a 100644 --- a/application/LaunchInteraction.cpp +++ b/application/LaunchInteraction.cpp @@ -14,6 +14,7 @@ #include <tasks/Task.h> #include <auth/YggdrasilTask.h> #include <launch/steps/TextPrint.h> +#include <QStringList> LaunchController::LaunchController(QObject *parent) : QObject(parent) { @@ -76,8 +77,9 @@ void LaunchController::login() // we loop until the user succeeds in logging in or gives up bool tryagain = true; // the failure. the default failure. - QString failReason = tr("Your account is currently not logged in. Please enter " + const QString needLoginAgain = tr("Your account is currently not logged in. Please enter " "your password to log in again."); + QString failReason = needLoginAgain; while (tryagain) { @@ -94,7 +96,12 @@ void LaunchController::login() progDialog.exec(task.get()); if (!task->successful()) { - failReason = task->failReason(); + auto failReasonNew = task->failReason(); + if(failReasonNew == "Invalid token.") + { + failReason = needLoginAgain; + } + else failReason = failReasonNew; } } switch (m_session->status) @@ -108,6 +115,26 @@ void LaunchController::login() case AuthSession::RequiresPassword: { EditAccountDialog passDialog(failReason, m_parentWidget, EditAccountDialog::PasswordField); + auto username = m_session->username; + auto chopN = [](QString toChop, int N) -> QString + { + if(toChop.size() > N) + { + auto left = toChop.left(N); + left += QString("\u25CF").repeated(toChop.size() - N); + return left; + } + return toChop; + }; + + if(username.contains('@')) + { + auto parts = username.split('@'); + auto mailbox = chopN(parts[0],3); + QString domain = chopN(parts[1], 3); + username = mailbox + '@' + domain; + } + passDialog.setUsername(username); if (passDialog.exec() == QDialog::Accepted) { password = passDialog.password(); |