Reword instance-specific account settings, apply clang-format
Signed-off-by: Aaron <10217842+byteduck@users.noreply.github.com>
This commit is contained in:
parent
eefb259ddf
commit
ba81ad1ac3
@ -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
|
// 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 instanceAccountId = m_instance->settings()->get("InstanceAccountId").toString();
|
||||||
auto instanceAccountIndex = accounts->findAccountByProfileId(instanceAccountId);
|
auto instanceAccountIndex = accounts->findAccountByProfileId(instanceAccountId);
|
||||||
if (instanceAccountIndex == -1)
|
if (instanceAccountIndex == -1) {
|
||||||
{
|
|
||||||
m_accountToUse = accounts->defaultAccount();
|
m_accountToUse = accounts->defaultAccount();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_accountToUse = accounts->at(instanceAccountIndex);
|
m_accountToUse = accounts->at(instanceAccountIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!m_accountToUse)
|
if (!m_accountToUse)
|
||||||
{
|
{
|
||||||
// If no default account is set, ask the user which one to use.
|
// If no default account is set, ask the user which one to use.
|
||||||
|
@ -283,8 +283,7 @@ void InstanceSettingsPage::applySettings()
|
|||||||
// Use an account for this instance
|
// Use an account for this instance
|
||||||
bool useAccountForInstance = ui->instanceAccountGroupBox->isChecked();
|
bool useAccountForInstance = ui->instanceAccountGroupBox->isChecked();
|
||||||
m_settings->set("UseAccountForInstance", useAccountForInstance);
|
m_settings->set("UseAccountForInstance", useAccountForInstance);
|
||||||
if (!useAccountForInstance)
|
if (!useAccountForInstance) {
|
||||||
{
|
|
||||||
m_settings->reset("InstanceAccountId");
|
m_settings->reset("InstanceAccountId");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,33 +458,33 @@ void InstanceSettingsPage::updateAccountsMenu()
|
|||||||
|
|
||||||
auto accounts = APPLICATION->accounts();
|
auto accounts = APPLICATION->accounts();
|
||||||
int accountIndex = accounts->findAccountByProfileId(m_settings->get("InstanceAccountId").toString());
|
int accountIndex = accounts->findAccountByProfileId(m_settings->get("InstanceAccountId").toString());
|
||||||
|
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
|
||||||
|
|
||||||
if (accountIndex != -1)
|
if (accountIndex != -1 && accounts->at(accountIndex)) {
|
||||||
{
|
defaultAccount = accounts->at(accountIndex);
|
||||||
auto account = accounts->at(accountIndex);
|
}
|
||||||
ui->instanceAccountSelector->setText(account->profileName());
|
|
||||||
ui->instanceAccountSelector->setIcon(account->getFace());
|
if (defaultAccount) {
|
||||||
|
ui->instanceAccountSelector->setText(defaultAccount->profileName());
|
||||||
|
ui->instanceAccountSelector->setIcon(defaultAccount->getFace());
|
||||||
} 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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
QAction* action = new QAction(account->profileName(), this);
|
QAction* action = new QAction(account->profileName(), this);
|
||||||
action->setData(i);
|
action->setData(i);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
if (accountIndex == i)
|
if (accountIndex == i) {
|
||||||
{
|
|
||||||
action->setChecked(true);
|
action->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto face = account->getFace();
|
auto face = account->getFace();
|
||||||
if (!face.isNull()) {
|
if (!face.isNull()) {
|
||||||
action->setIcon(face);
|
action->setIcon(face);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
action->setIcon(APPLICATION->getThemedIcon("noaccount"));
|
action->setIcon(APPLICATION->getThemedIcon("noaccount"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,18 +497,12 @@ void InstanceSettingsPage::changeInstanceAccount()
|
|||||||
{
|
{
|
||||||
QAction* sAction = (QAction*)sender();
|
QAction* sAction = (QAction*)sender();
|
||||||
|
|
||||||
// Profile's associated Mojang username
|
|
||||||
Q_ASSERT(sAction->data().type() == QVariant::Type::Int);
|
Q_ASSERT(sAction->data().type() == QVariant::Type::Int);
|
||||||
|
|
||||||
QVariant data = sAction->data();
|
QVariant data = sAction->data();
|
||||||
bool valid = false;
|
int index = data.toInt();
|
||||||
int index = data.toInt(&valid);
|
|
||||||
if(!valid) {
|
|
||||||
index = -1;
|
|
||||||
}
|
|
||||||
auto accounts = APPLICATION->accounts();
|
auto accounts = APPLICATION->accounts();
|
||||||
auto account = accounts->at(index);
|
auto account = accounts->at(index);
|
||||||
|
|
||||||
m_settings->set("InstanceAccountId", account->profileId());
|
m_settings->set("InstanceAccountId", account->profileId());
|
||||||
|
|
||||||
ui->instanceAccountSelector->setText(account->profileName());
|
ui->instanceAccountSelector->setText(account->profileName());
|
||||||
|
@ -611,7 +611,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="instanceAccountGroupBox">
|
<widget class="QGroupBox" name="instanceAccountGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Set a default account to use with this instance</string>
|
<string>Override default account</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
Loading…
Reference in New Issue
Block a user