Fix instance account selector face for offline accounts

This commit is contained in:
Aaron 2023-01-12 20:03:31 -08:00
parent e0e3d4d8fe
commit 160dd09fc2
No known key found for this signature in database
GPG Key ID: 581231D4749818AE
2 changed files with 13 additions and 14 deletions

View File

@ -466,7 +466,7 @@ void InstanceSettingsPage::updateAccountsMenu()
if (defaultAccount) { if (defaultAccount) {
ui->instanceAccountSelector->setText(defaultAccount->profileName()); ui->instanceAccountSelector->setText(defaultAccount->profileName());
ui->instanceAccountSelector->setIcon(defaultAccount->getFace()); ui->instanceAccountSelector->setIcon(getFaceForAccount(defaultAccount));
} else { } else {
ui->instanceAccountSelector->setText(tr("No default account")); ui->instanceAccountSelector->setText(tr("No default account"));
ui->instanceAccountSelector->setIcon(APPLICATION->getThemedIcon("noaccount")); ui->instanceAccountSelector->setIcon(APPLICATION->getThemedIcon("noaccount"));
@ -480,19 +480,21 @@ void InstanceSettingsPage::updateAccountsMenu()
if (accountIndex == i) { if (accountIndex == i) {
action->setChecked(true); action->setChecked(true);
} }
action->setIcon(getFaceForAccount(account));
auto face = account->getFace();
if (!face.isNull()) {
action->setIcon(face);
} else {
action->setIcon(APPLICATION->getThemedIcon("noaccount"));
}
accountMenu->addAction(action); accountMenu->addAction(action);
connect(action, SIGNAL(triggered(bool)), this, SLOT(changeInstanceAccount())); connect(action, SIGNAL(triggered(bool)), this, SLOT(changeInstanceAccount()));
} }
} }
QIcon InstanceSettingsPage::getFaceForAccount(MinecraftAccountPtr account)
{
if (auto face = account->getFace(); !face.isNull()) {
return face;
}
return APPLICATION->getThemedIcon("noaccount");
}
void InstanceSettingsPage::changeInstanceAccount() void InstanceSettingsPage::changeInstanceAccount()
{ {
QAction* sAction = (QAction*)sender(); QAction* sAction = (QAction*)sender();
@ -506,11 +508,7 @@ void InstanceSettingsPage::changeInstanceAccount()
m_settings->set("InstanceAccountId", account->profileId()); m_settings->set("InstanceAccountId", account->profileId());
ui->instanceAccountSelector->setText(account->profileName()); ui->instanceAccountSelector->setText(account->profileName());
if (auto face = account->getFace(); !face.isNull()) { ui->instanceAccountSelector->setIcon(getFaceForAccount(account));
ui->instanceAccountSelector->setIcon(face);
} else {
ui->instanceAccountSelector->setIcon(APPLICATION->getThemedIcon("noaccount"));
}
} }
void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i) void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i)

View File

@ -94,6 +94,7 @@ private slots:
void globalSettingsButtonClicked(bool checked); void globalSettingsButtonClicked(bool checked);
void updateAccountsMenu(); void updateAccountsMenu();
QIcon getFaceForAccount(MinecraftAccountPtr account);
void changeInstanceAccount(); void changeInstanceAccount();
private: private: