Launcher: fix bugs deleting profiles (Fixes #2188)

moveref
scrawl 10 years ago
parent fb1aa096be
commit 1937ace1b7

@ -154,9 +154,11 @@ void Launcher::DataFilesPage::setProfile(int index, bool savePrevious)
{
if (index >= -1 && index < ui.profilesComboBox->count())
{
QString previous = ui.profilesComboBox->itemText(ui.profilesComboBox->currentIndex());
QString previous = mPreviousProfile;
QString current = ui.profilesComboBox->itemText(index);
mPreviousProfile = current;
setProfile (previous, current, savePrevious);
}
}
@ -167,9 +169,6 @@ void Launcher::DataFilesPage::setProfile (const QString &previous, const QString
if (previous == current)
return;
if (previous.isEmpty())
return;
if (!previous.isEmpty() && savePrevious)
saveSettings (previous);
@ -212,7 +211,7 @@ void Launcher::DataFilesPage::slotProfileChanged(int index)
void Launcher::DataFilesPage::on_newProfileAction_triggered()
{
if (!mProfileDialog->exec() == QDialog::Accepted)
if (mProfileDialog->exec() != QDialog::Accepted)
return;
QString profile = mProfileDialog->lineEdit()->text();
@ -222,9 +221,10 @@ void Launcher::DataFilesPage::on_newProfileAction_triggered()
saveSettings();
mSelector->clearCheckStates();
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
addProfile(profile, true);
mSelector->clearCheckStates();
mSelector->setGameFile();
@ -255,10 +255,12 @@ void Launcher::DataFilesPage::on_deleteProfileAction_triggered()
if (!showDeleteMessageBox (profile))
return;
// Remove the profile from the combobox
ui.profilesComboBox->removeItem (ui.profilesComboBox->findText (profile));
// this should work since the Default profile can't be deleted and is always index 0
int next = ui.profilesComboBox->currentIndex()-1;
ui.profilesComboBox->setCurrentIndex(next);
removeProfile(profile);
ui.profilesComboBox->removeItem(ui.profilesComboBox->findText(profile));
saveSettings();

@ -67,6 +67,8 @@ namespace Launcher
Config::GameSettings &mGameSettings;
Config::LauncherSettings &mLauncherSettings;
QString mPreviousProfile;
QString mDataLocal;
void setPluginsCheckstates(Qt::CheckState state);

Loading…
Cancel
Save