Reword instance-specific account settings, apply clang-format

Signed-off-by: Aaron <10217842+byteduck@users.noreply.github.com>
This commit is contained in:
Aaron 2023-01-02 11:16:09 -07:00
parent eefb259ddf
commit ba81ad1ac3
3 changed files with 19 additions and 30 deletions

View File

@ -115,16 +115,12 @@ void LaunchController::decideAccount()
// Select the account to use. If the instance has a specific account set, that will be used. Otherwise, the default account will be used
auto instanceAccountId = m_instance->settings()->get("InstanceAccountId").toString();
auto instanceAccountIndex = accounts->findAccountByProfileId(instanceAccountId);
if (instanceAccountIndex == -1)
{
if (instanceAccountIndex == -1) {
m_accountToUse = accounts->defaultAccount();
}
else
{
} else {
m_accountToUse = accounts->at(instanceAccountIndex);
}
if (!m_accountToUse)
{
// If no default account is set, ask the user which one to use.

View File

@ -283,8 +283,7 @@ void InstanceSettingsPage::applySettings()
// Use an account for this instance
bool useAccountForInstance = ui->instanceAccountGroupBox->isChecked();
m_settings->set("UseAccountForInstance", useAccountForInstance);
if (!useAccountForInstance)
{
if (!useAccountForInstance) {
m_settings->reset("InstanceAccountId");
}
@ -459,33 +458,33 @@ void InstanceSettingsPage::updateAccountsMenu()
auto accounts = APPLICATION->accounts();
int accountIndex = accounts->findAccountByProfileId(m_settings->get("InstanceAccountId").toString());
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
if (accountIndex != -1)
{
auto account = accounts->at(accountIndex);
ui->instanceAccountSelector->setText(account->profileName());
ui->instanceAccountSelector->setIcon(account->getFace());
if (accountIndex != -1 && accounts->at(accountIndex)) {
defaultAccount = accounts->at(accountIndex);
}
if (defaultAccount) {
ui->instanceAccountSelector->setText(defaultAccount->profileName());
ui->instanceAccountSelector->setIcon(defaultAccount->getFace());
} else {
ui->instanceAccountSelector->setText(tr("No default account"));
ui->instanceAccountSelector->setIcon(APPLICATION->getThemedIcon("noaccount"));
}
for (int i = 0; i < accounts->count(); i++)
{
for (int i = 0; i < accounts->count(); i++) {
MinecraftAccountPtr account = accounts->at(i);
QAction* action = new QAction(account->profileName(), this);
action->setData(i);
action->setCheckable(true);
if (accountIndex == i)
{
if (accountIndex == i) {
action->setChecked(true);
}
auto face = account->getFace();
if (!face.isNull()) {
action->setIcon(face);
}
else {
} else {
action->setIcon(APPLICATION->getThemedIcon("noaccount"));
}
@ -498,18 +497,12 @@ void InstanceSettingsPage::changeInstanceAccount()
{
QAction* sAction = (QAction*)sender();
// Profile's associated Mojang username
Q_ASSERT(sAction->data().type() == QVariant::Type::Int);
QVariant data = sAction->data();
bool valid = false;
int index = data.toInt(&valid);
if(!valid) {
index = -1;
}
int index = data.toInt();
auto accounts = APPLICATION->accounts();
auto account = accounts->at(index);
m_settings->set("InstanceAccountId", account->profileId());
ui->instanceAccountSelector->setText(account->profileName());

View File

@ -611,7 +611,7 @@
<item>
<widget class="QGroupBox" name="instanceAccountGroupBox">
<property name="title">
<string>Set a default account to use with this instance</string>
<string>Override default account</string>
</property>
<property name="checkable">
<bool>true</bool>