mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 09:39:41 +00:00
Fixed problem with profile writeout
This commit is contained in:
parent
314bac7862
commit
2e058409bd
2 changed files with 38 additions and 4 deletions
|
@ -136,7 +136,7 @@ void DataFilesPage::newProfile()
|
||||||
if (mProfilesComboBox->findText(text) != -1)
|
if (mProfilesComboBox->findText(text) != -1)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Profile already exists"),
|
QMessageBox::warning(this, tr("Profile already exists"),
|
||||||
tr("the profile %0 already exists.").arg(text),
|
tr("the profile <b>%0</b> already exists.").arg(text),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
} else {
|
} else {
|
||||||
// Add the new profile to the combobox
|
// Add the new profile to the combobox
|
||||||
|
@ -147,8 +147,18 @@ void DataFilesPage::newProfile()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//textLabel->setText(text);
|
}
|
||||||
|
|
||||||
|
void DataFilesPage::deleteProfile()
|
||||||
|
{
|
||||||
|
QString profile = mProfilesComboBox->currentText();
|
||||||
|
|
||||||
|
|
||||||
|
if (!profile.isEmpty()) {
|
||||||
|
QMessageBox::warning(this, tr("Delete profile"),
|
||||||
|
tr("Are you sure you want to remove <b>%0.</b>").arg(profile),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::setupDataFiles(const QString &path)
|
void DataFilesPage::setupDataFiles(const QString &path)
|
||||||
|
@ -236,6 +246,7 @@ void DataFilesPage::setupDataFiles(const QString &path)
|
||||||
|
|
||||||
void DataFilesPage::setupConfig()
|
void DataFilesPage::setupConfig()
|
||||||
{
|
{
|
||||||
|
qDebug() << "setupConfig called";
|
||||||
QString config = "launcher.cfg";
|
QString config = "launcher.cfg";
|
||||||
QFile file(config);
|
QFile file(config);
|
||||||
|
|
||||||
|
@ -246,24 +257,38 @@ void DataFilesPage::setupConfig()
|
||||||
|
|
||||||
file.setFileName(config); // Just for displaying information
|
file.setFileName(config); // Just for displaying information
|
||||||
qDebug() << "Using config file from " << file.fileName();
|
qDebug() << "Using config file from " << file.fileName();
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
qDebug() << "File contents:" << file.readAll();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
// Open our config file
|
// Open our config file
|
||||||
mLauncherConfig = new QSettings(config, QSettings::IniFormat);
|
mLauncherConfig = new QSettings(config, QSettings::IniFormat);
|
||||||
|
mLauncherConfig->sync();
|
||||||
|
|
||||||
|
|
||||||
|
// Make sure we have no groups open
|
||||||
|
while (!mLauncherConfig->group().isEmpty()) {
|
||||||
|
mLauncherConfig->endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
mLauncherConfig->beginGroup("Profiles");
|
mLauncherConfig->beginGroup("Profiles");
|
||||||
QStringList profiles = mLauncherConfig->childGroups();
|
QStringList profiles = mLauncherConfig->childGroups();
|
||||||
|
|
||||||
if (profiles.isEmpty()) {
|
/*if (profiles.isEmpty()) {
|
||||||
// Add a default profile
|
// Add a default profile
|
||||||
profiles.append("Default");
|
profiles.append("Default");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//mProfilesModel->setStringList(profiles);
|
//mProfilesModel->setStringList(profiles);
|
||||||
mProfilesComboBox->addItems(profiles);
|
mProfilesComboBox->addItems(profiles);
|
||||||
|
|
||||||
QString currentProfile = mLauncherConfig->value("CurrentProfile").toString();
|
QString currentProfile = mLauncherConfig->value("CurrentProfile").toString();
|
||||||
|
|
||||||
|
qDebug() << mLauncherConfig->value("CurrentProfile").toString();
|
||||||
|
qDebug() << mLauncherConfig->childGroups();
|
||||||
|
|
||||||
if (currentProfile.isEmpty()) {
|
if (currentProfile.isEmpty()) {
|
||||||
|
qDebug() << "No current profile selected";
|
||||||
currentProfile = "Default";
|
currentProfile = "Default";
|
||||||
}
|
}
|
||||||
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(currentProfile));
|
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(currentProfile));
|
||||||
|
@ -440,6 +465,9 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre
|
||||||
{
|
{
|
||||||
qDebug() << "Profile changed " << current << previous;
|
qDebug() << "Profile changed " << current << previous;
|
||||||
|
|
||||||
|
//if (previous.isEmpty()) {
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
// Just to be sure
|
// Just to be sure
|
||||||
if (!previous.isEmpty()) {
|
if (!previous.isEmpty()) {
|
||||||
writeConfig(previous);
|
writeConfig(previous);
|
||||||
|
@ -502,6 +530,10 @@ void DataFilesPage::writeConfig(QString profile)
|
||||||
profile = mProfilesComboBox->currentText();
|
profile = mProfilesComboBox->currentText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (profile.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "Writing: " << profile;
|
qDebug() << "Writing: " << profile;
|
||||||
|
|
||||||
// Make sure we have no groups open
|
// Make sure we have no groups open
|
||||||
|
@ -513,6 +545,7 @@ void DataFilesPage::writeConfig(QString profile)
|
||||||
mLauncherConfig->setValue("CurrentProfile", profile);
|
mLauncherConfig->setValue("CurrentProfile", profile);
|
||||||
|
|
||||||
// Open the profile-name subgroup
|
// Open the profile-name subgroup
|
||||||
|
qDebug() << "beginning group: " << profile;
|
||||||
mLauncherConfig->beginGroup(profile);
|
mLauncherConfig->beginGroup(profile);
|
||||||
mLauncherConfig->remove(""); // Clear the subgroup
|
mLauncherConfig->remove(""); // Clear the subgroup
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ public slots:
|
||||||
void resizeRows();
|
void resizeRows();
|
||||||
void profileChanged(const QString &previous, const QString ¤t);
|
void profileChanged(const QString &previous, const QString ¤t);
|
||||||
void newProfile();
|
void newProfile();
|
||||||
|
void deleteProfile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTableWidget *mMastersWidget;
|
QTableWidget *mMastersWidget;
|
||||||
|
|
Loading…
Reference in a new issue