fix: use profile id for per-instance account override
Signed-off-by: Lenny McLennington <lenny@sneed.church>
This commit is contained in:
parent
5d9ff3767a
commit
de1de47940
@ -113,9 +113,17 @@ void LaunchController::decideAccount()
|
||||
}
|
||||
|
||||
bool overrideAccount = m_instance->settings()->get("OverrideAccount").toBool();
|
||||
int overrideAccountIndex = m_instance->settings()->get("OverrideAccountIndex").toInt();
|
||||
QString overrideAccountProfileId = m_instance->settings()->get("OverrideAccountProfileId").toString();
|
||||
|
||||
m_accountToUse = accounts->defaultAccount();
|
||||
|
||||
if (overrideAccount) {
|
||||
int overrideIndex = accounts->findAccountByProfileId(overrideAccountProfileId);
|
||||
if (overrideIndex != -1) {
|
||||
m_accountToUse = accounts->at(overrideIndex);
|
||||
}
|
||||
}
|
||||
|
||||
m_accountToUse = !overrideAccount ? accounts->defaultAccount() : accounts->at(overrideAccountIndex);
|
||||
if (!m_accountToUse)
|
||||
{
|
||||
// If no default account is set, ask the user which one to use.
|
||||
|
@ -190,7 +190,7 @@ void MinecraftInstance::loadSpecificSettings()
|
||||
|
||||
// Account override
|
||||
m_settings->registerSetting("OverrideAccount", false);
|
||||
m_settings->registerSetting("OverrideAccountIndex", -1);
|
||||
m_settings->registerSetting("OverrideAccountProfileId", "");
|
||||
|
||||
qDebug() << "Instance-type specific settings were loaded!";
|
||||
|
||||
|
@ -281,13 +281,13 @@ void InstanceSettingsPage::applySettings()
|
||||
// Account override settings
|
||||
bool accountOverride = ui->accountGroupBox->isChecked();
|
||||
m_settings->set("OverrideAccount", accountOverride);
|
||||
if (accountOverride)
|
||||
if (accountOverride && ui->accountComboBox->currentData().isValid())
|
||||
{
|
||||
m_settings->set("OverrideAccountIndex", ui->accountComboBox->currentIndex());
|
||||
m_settings->set("OverrideAccountProfileId", ui->accountComboBox->currentData().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings->reset("OverrideAccountIndex");
|
||||
m_settings->reset("OverrideAccountProfileId");
|
||||
}
|
||||
|
||||
// FIXME: This should probably be called by a signal instead
|
||||
@ -394,18 +394,24 @@ void InstanceSettingsPage::loadSettings()
|
||||
MinecraftAccountPtr account = m_accounts->at(i);
|
||||
|
||||
QString profileLabel = account->profileName();
|
||||
QString profileId = account->profileId();
|
||||
QString profileType = account->typeString();
|
||||
profileType[0] = profileType[0].toUpper();
|
||||
QPixmap profileFace = account->getFace();
|
||||
QIcon profileIcon = !profileFace.isNull() ? QIcon(profileFace) : APPLICATION->getThemedIcon("noaccount");
|
||||
|
||||
ui->accountComboBox->addItem(profileIcon, QString("%1 (%2)").arg(profileLabel, profileType));
|
||||
ui->accountComboBox->addItem(profileIcon, QString("%1 (%2)").arg(profileLabel, profileType), profileId);
|
||||
}
|
||||
|
||||
int accountIndex = m_settings->get("OverrideAccountIndex").toInt();
|
||||
if (accountIndex >= 0 && accountIndex < m_accounts->count()) {
|
||||
ui->accountComboBox->setCurrentIndex(accountIndex);
|
||||
QString accountProfileId = m_settings->get("OverrideAccountProfileId").toString();
|
||||
int index = -1;
|
||||
if (ui->accountGroupBox->isChecked()) {
|
||||
// Try find the account by the override profile id setting
|
||||
// It'll be -1 if the account doesn't exist, which will just
|
||||
// Set the combobox to the "no option selected" state
|
||||
index = ui->accountComboBox->findData(accountProfileId);
|
||||
}
|
||||
ui->accountComboBox->setCurrentIndex(index);
|
||||
} else {
|
||||
ui->accountComboBox->addItem(tr("No accounts available"));
|
||||
ui->accountComboBox->setDisabled(true);
|
||||
|
Loading…
Reference in New Issue
Block a user