Various fixes and changes to the settings handling

actorid
Pieter van der Kloet 12 years ago
parent 919d1ee572
commit 17a0a201df

@ -19,23 +19,6 @@
#include "datafilespage.hpp"
#include <boost/version.hpp>
/**
* Workaround for problems with whitespaces in paths in older versions of Boost library
*/
#if (BOOST_VERSION <= 104600)
namespace boost
{
template<>
inline boost::filesystem::path lexical_cast<boost::filesystem::path, std::string>(const std::string& arg)
{
return boost::filesystem::path(arg);
}
} /* namespace boost */
#endif /* (BOOST_VERSION <= 104600) */
using namespace ESM;
using namespace std;
@ -241,7 +224,7 @@ void DataFilesPage::setupDataFiles()
mDataFilesModel->sort(3);
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
QString profile = mLauncherSettings.value(QString("Profiles/CurrentProfile"));
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
mProfilesComboBox->setCurrentIndex(-1);
mProfilesComboBox->addItems(profiles);
@ -271,7 +254,7 @@ void DataFilesPage::setupDataFiles()
void DataFilesPage::loadSettings()
{
QString profile = mLauncherSettings.value(QString("Profiles/CurrentProfile"));
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
if (profile.isEmpty())
return;
@ -299,10 +282,12 @@ void DataFilesPage::saveSettings()
if (mDataFilesModel->rowCount() < 1)
return;
QString profile = mLauncherSettings.value(QString("Profiles/CurrentProfile"));
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
if (profile.isEmpty())
return;
if (profile.isEmpty()) {
profile = mProfilesComboBox->currentText();
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
}
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master"));
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
@ -539,9 +524,9 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre
return; // Profile was deleted
// Store the previous profile
mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), previous);
mLauncherSettings.setValue(QString("Profiles/currentprofile"), previous);
saveSettings();
mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), current);
mLauncherSettings.setValue(QString("Profiles/currentprofile"), current);
loadSettings();
}
@ -552,7 +537,7 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
return;
// Save the new profile name
mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), current);
mLauncherSettings.setValue(QString("Profiles/currentprofile"), current);
saveSettings();
// Remove the old one

@ -196,7 +196,7 @@ void GraphicsPage::loadSettings()
resolution.append(QString(" x ") + mGraphicsSettings.value(QString("Video/resolution y")));
int resIndex = mResolutionComboBox->findText(resolution, Qt::MatchStartsWith);
qDebug() << "resolution from file: " << resolution;
if (resIndex != -1)
mResolutionComboBox->setCurrentIndex(resIndex);
}

@ -8,6 +8,23 @@
#include <components/files/configurationmanager.hpp>
#include <boost/version.hpp>
/**
* Workaround for problems with whitespaces in paths in older versions of Boost library
*/
#if (BOOST_VERSION <= 104600)
namespace boost
{
template<>
inline boost::filesystem::path lexical_cast<boost::filesystem::path, std::string>(const std::string& arg)
{
return boost::filesystem::path(arg);
}
} /* namespace boost */
#endif /* (BOOST_VERSION <= 104600) */
#include "gamesettings.hpp"
GameSettings::GameSettings(Files::ConfigurationManager &cfg)
@ -93,6 +110,8 @@ bool GameSettings::readFile(QTextStream &stream)
mSettings.remove(key);
QStringList values = cache.values(key);
values.append(mSettings.values(key));
if (!values.contains(value)) {
cache.insertMulti(key, value);
}
@ -125,9 +144,16 @@ bool GameSettings::writeFile(QTextStream &stream)
continue;
// Quote paths with spaces
if (i.key() == QLatin1String("data")) {
if (i.value().contains(" ")) {
stream << i.key() << "=\"" << i.value() << "\"\n";
if (i.key() == QLatin1String("data")
|| i.key() == QLatin1String("data-local")
|| i.key() == QLatin1String("resources"))
{
if (i.value().contains(QChar(' ')))
{
QString stripped = i.value();
stripped.remove(QChar('\"')); // Remove quotes
stream << i.key() << "=\"" << stripped << "\"\n";
continue;
}
}

@ -66,6 +66,7 @@ bool LauncherSettings::writeFile(QTextStream &stream)
QString sectionPrefix;
QRegExp sectionRe("([^/]+)/(.+)$");
QMap<QString, QString> settings = SettingsBase::getSettings();
qDebug() << "writing " << settings;
QMapIterator<QString, QString> i(settings);
i.toBack();
@ -81,6 +82,13 @@ bool LauncherSettings::writeFile(QTextStream &stream)
key = sectionRe.cap(2);
}
// Get rid of legacy settings
if (key.contains(QChar('\\')))
continue;
if (key == QLatin1String("CurrentProfile"))
continue;
if (sectionPrefix != prefix) {
sectionPrefix = prefix;
stream << "\n[" << prefix << "]\n";

Loading…
Cancel
Save