Use indexes instead of account name. Added "no accounts" indication. Added account type to combo box string.
Signed-off-by: urFate <georgiylakidon@gmail.com>
This commit is contained in:
parent
2a7c666932
commit
ce1a48be5d
@ -113,9 +113,9 @@ void LaunchController::decideAccount()
|
||||
}
|
||||
|
||||
bool overrideAccount = m_instance->settings()->get("OverrideAccount").toBool();
|
||||
QString overrideAccountName = m_instance->settings()->get("OverrideAccountName").toString();
|
||||
int overrideAccountIndex = m_instance->settings()->get("OverrideAccountIndex").toInt();
|
||||
|
||||
m_accountToUse = !overrideAccount ? accounts->defaultAccount() : accounts->getAccountByProfileName(overrideAccountName);
|
||||
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("OverrideAccountName", "");
|
||||
m_settings->registerSetting("OverrideAccountIndex", -1);
|
||||
|
||||
qDebug() << "Instance-type specific settings were loaded!";
|
||||
|
||||
|
@ -283,11 +283,11 @@ void InstanceSettingsPage::applySettings()
|
||||
m_settings->set("OverrideAccount", accountOverride);
|
||||
if (accountOverride)
|
||||
{
|
||||
m_settings->set("OverrideAccountName", ui->accountComboBox->currentText());
|
||||
m_settings->set("OverrideAccountIndex", ui->accountComboBox->currentIndex());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings->reset("OverrideAccountName");
|
||||
m_settings->reset("OverrideAccountIndex");
|
||||
}
|
||||
|
||||
// FIXME: This should probably be called by a signal instead
|
||||
@ -388,19 +388,28 @@ void InstanceSettingsPage::loadSettings()
|
||||
ui->serverJoinGroupBox->setChecked(m_settings->get("JoinServerOnLaunch").toBool());
|
||||
ui->serverJoinAddress->setText(m_settings->get("JoinServerOnLaunchAddress").toString());
|
||||
|
||||
for (int i = 0; i < m_accounts->count(); ++i) {
|
||||
MinecraftAccountPtr account = m_accounts->at(i);
|
||||
|
||||
QString profileLabel = account->profileName();
|
||||
QPixmap profileFace = account->getFace();
|
||||
QIcon profileIcon = !profileFace.isNull() ? QIcon(profileFace) : APPLICATION->getThemedIcon("noaccount");
|
||||
|
||||
ui->accountComboBox->addItem(profileIcon, profileLabel);
|
||||
}
|
||||
int accountIndex = ui->accountComboBox->findText(m_settings->get("OverrideAccountName").toString());
|
||||
|
||||
ui->accountGroupBox->setChecked(m_settings->get("OverrideAccount").toBool());
|
||||
ui->accountComboBox->setCurrentIndex(accountIndex == -1 ? 0 : accountIndex);
|
||||
if (m_accounts->count() > 0) {
|
||||
for (int i = 0; i < m_accounts->count(); i++) {
|
||||
MinecraftAccountPtr account = m_accounts->at(i);
|
||||
|
||||
QString profileLabel = account->profileName();
|
||||
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));
|
||||
}
|
||||
|
||||
int accountIndex = m_settings->get("OverrideAccountIndex").toInt();
|
||||
if (accountIndex >= 0 && accountIndex < m_accounts->count()) {
|
||||
ui->accountComboBox->setCurrentIndex(accountIndex);
|
||||
}
|
||||
} else {
|
||||
ui->accountComboBox->addItem(tr("No accounts available"));
|
||||
ui->accountComboBox->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceSettingsPage::on_javaDetectBtn_clicked()
|
||||
|
Loading…
Reference in New Issue
Block a user