Some ui fixes

This commit is contained in:
max
2021-11-05 10:31:18 +03:00
parent ff8c2aab1b
commit deffca3b6f
2 changed files with 11 additions and 12 deletions

View File

@@ -91,16 +91,15 @@
#include "MMCTime.h" #include "MMCTime.h"
namespace { 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); additionalPart += ", in use";
}
else
{
return profile;
} }
return ((QString)"%1 (%2)").arg(account->profileName(), additionalPart);
} }
} }
@@ -847,7 +846,7 @@ void MainWindow::retranslateUi()
std::shared_ptr<AccountList> accounts = LAUNCHER->accounts(); std::shared_ptr<AccountList> accounts = LAUNCHER->accounts();
MinecraftAccountPtr active_account = accounts->activeAccount(); MinecraftAccountPtr active_account = accounts->activeAccount();
if(active_account) { if(active_account) {
auto profileLabel = profileInUseFilter(active_account->profileName(), active_account->isInUse()); auto profileLabel = getProfileDisplay(active_account);
accountMenuButton->setText(profileLabel); accountMenuButton->setText(profileLabel);
} }
else { else {
@@ -1034,7 +1033,7 @@ void MainWindow::repopulateAccountsMenu()
// this can be called before accountMenuButton exists // this can be called before accountMenuButton exists
if (accountMenuButton) if (accountMenuButton)
{ {
auto profileLabel = profileInUseFilter(active_account->profileName(), active_account->isInUse()); auto profileLabel = getProfileDisplay(active_account);
accountMenuButton->setText(profileLabel); accountMenuButton->setText(profileLabel);
} }
} }
@@ -1051,7 +1050,7 @@ void MainWindow::repopulateAccountsMenu()
for (int i = 0; i < accounts->count(); i++) for (int i = 0; i < accounts->count(); i++)
{ {
MinecraftAccountPtr account = accounts->at(i); MinecraftAccountPtr account = accounts->at(i);
auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse()); auto profileLabel = getProfileDisplay(account);
QAction *action = new QAction(profileLabel, this); QAction *action = new QAction(profileLabel, this);
action->setData(account->profileId()); action->setData(account->profileId());
action->setCheckable(true); action->setCheckable(true);
@@ -1124,7 +1123,7 @@ void MainWindow::activeAccountChanged()
// FIXME: this needs adjustment for MSA // FIXME: this needs adjustment for MSA
if (account != nullptr && account->profileName() != "") if (account != nullptr && account->profileName() != "")
{ {
auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse()); auto profileLabel = getProfileDisplay(account);
accountMenuButton->setText(profileLabel); accountMenuButton->setText(profileLabel);
accountMenuButton->setIcon(account->getFace()); accountMenuButton->setIcon(account->getFace());
return; return;

View File

@@ -143,7 +143,7 @@ public: /* queries */
if(data.legacy) { if(data.legacy) {
return "legacy"; return "legacy";
} }
return "mojang"; return data.provider->displayName();
} }
break; break;
case AccountType::MSA: { case AccountType::MSA: {