From deffca3b6f84cfe0d5932b096da7ec216f3408df Mon Sep 17 00:00:00 2001 From: max Date: Fri, 5 Nov 2021 10:31:18 +0300 Subject: [PATCH] Some ui fixes --- launcher/MainWindow.cpp | 21 ++++++++++----------- launcher/minecraft/auth/MinecraftAccount.h | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/launcher/MainWindow.cpp b/launcher/MainWindow.cpp index 21502894..7e210a66 100644 --- a/launcher/MainWindow.cpp +++ b/launcher/MainWindow.cpp @@ -91,16 +91,15 @@ #include "MMCTime.h" namespace { -QString profileInUseFilter(const QString & profile, bool used) +QString getProfileDisplay(MinecraftAccountPtr account) { - if(used) + QString additionalPart = account->typeString(); + if(account->isInUse()) { - return QObject::tr("%1 (in use)").arg(profile); - } - else - { - return profile; + additionalPart += ", in use"; } + + return ((QString)"%1 (%2)").arg(account->profileName(), additionalPart); } } @@ -847,7 +846,7 @@ void MainWindow::retranslateUi() std::shared_ptr accounts = LAUNCHER->accounts(); MinecraftAccountPtr active_account = accounts->activeAccount(); if(active_account) { - auto profileLabel = profileInUseFilter(active_account->profileName(), active_account->isInUse()); + auto profileLabel = getProfileDisplay(active_account); accountMenuButton->setText(profileLabel); } else { @@ -1034,7 +1033,7 @@ void MainWindow::repopulateAccountsMenu() // this can be called before accountMenuButton exists if (accountMenuButton) { - auto profileLabel = profileInUseFilter(active_account->profileName(), active_account->isInUse()); + auto profileLabel = getProfileDisplay(active_account); accountMenuButton->setText(profileLabel); } } @@ -1051,7 +1050,7 @@ void MainWindow::repopulateAccountsMenu() for (int i = 0; i < accounts->count(); i++) { MinecraftAccountPtr account = accounts->at(i); - auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse()); + auto profileLabel = getProfileDisplay(account); QAction *action = new QAction(profileLabel, this); action->setData(account->profileId()); action->setCheckable(true); @@ -1124,7 +1123,7 @@ void MainWindow::activeAccountChanged() // FIXME: this needs adjustment for MSA if (account != nullptr && account->profileName() != "") { - auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse()); + auto profileLabel = getProfileDisplay(account); accountMenuButton->setText(profileLabel); accountMenuButton->setIcon(account->getFace()); return; diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h index 2188d7e4..c2a0340e 100644 --- a/launcher/minecraft/auth/MinecraftAccount.h +++ b/launcher/minecraft/auth/MinecraftAccount.h @@ -143,7 +143,7 @@ public: /* queries */ if(data.legacy) { return "legacy"; } - return "mojang"; + return data.provider->displayName(); } break; case AccountType::MSA: {