mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 14:09:39 +00:00
Various fixes and changes to the settings handling
This commit is contained in:
parent
919d1ee572
commit
17a0a201df
4 changed files with 48 additions and 29 deletions
|
@ -19,23 +19,6 @@
|
||||||
|
|
||||||
#include "datafilespage.hpp"
|
#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 ESM;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -241,7 +224,7 @@ void DataFilesPage::setupDataFiles()
|
||||||
mDataFilesModel->sort(3);
|
mDataFilesModel->sort(3);
|
||||||
|
|
||||||
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/CurrentProfile"));
|
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||||
|
|
||||||
mProfilesComboBox->setCurrentIndex(-1);
|
mProfilesComboBox->setCurrentIndex(-1);
|
||||||
mProfilesComboBox->addItems(profiles);
|
mProfilesComboBox->addItems(profiles);
|
||||||
|
@ -271,7 +254,7 @@ void DataFilesPage::setupDataFiles()
|
||||||
|
|
||||||
void DataFilesPage::loadSettings()
|
void DataFilesPage::loadSettings()
|
||||||
{
|
{
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/CurrentProfile"));
|
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||||
|
|
||||||
if (profile.isEmpty())
|
if (profile.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -299,10 +282,12 @@ void DataFilesPage::saveSettings()
|
||||||
if (mDataFilesModel->rowCount() < 1)
|
if (mDataFilesModel->rowCount() < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/CurrentProfile"));
|
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||||
|
|
||||||
if (profile.isEmpty())
|
if (profile.isEmpty()) {
|
||||||
return;
|
profile = mProfilesComboBox->currentText();
|
||||||
|
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
|
||||||
|
}
|
||||||
|
|
||||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master"));
|
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master"));
|
||||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
|
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
|
||||||
|
@ -539,9 +524,9 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre
|
||||||
return; // Profile was deleted
|
return; // Profile was deleted
|
||||||
|
|
||||||
// Store the previous profile
|
// Store the previous profile
|
||||||
mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), previous);
|
mLauncherSettings.setValue(QString("Profiles/currentprofile"), previous);
|
||||||
saveSettings();
|
saveSettings();
|
||||||
mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), current);
|
mLauncherSettings.setValue(QString("Profiles/currentprofile"), current);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
@ -552,7 +537,7 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Save the new profile name
|
// Save the new profile name
|
||||||
mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), current);
|
mLauncherSettings.setValue(QString("Profiles/currentprofile"), current);
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
// Remove the old one
|
// Remove the old one
|
||||||
|
|
|
@ -196,7 +196,7 @@ void GraphicsPage::loadSettings()
|
||||||
resolution.append(QString(" x ") + mGraphicsSettings.value(QString("Video/resolution y")));
|
resolution.append(QString(" x ") + mGraphicsSettings.value(QString("Video/resolution y")));
|
||||||
|
|
||||||
int resIndex = mResolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
int resIndex = mResolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
||||||
qDebug() << "resolution from file: " << resolution;
|
|
||||||
if (resIndex != -1)
|
if (resIndex != -1)
|
||||||
mResolutionComboBox->setCurrentIndex(resIndex);
|
mResolutionComboBox->setCurrentIndex(resIndex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,23 @@
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#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"
|
#include "gamesettings.hpp"
|
||||||
|
|
||||||
GameSettings::GameSettings(Files::ConfigurationManager &cfg)
|
GameSettings::GameSettings(Files::ConfigurationManager &cfg)
|
||||||
|
@ -93,6 +110,8 @@ bool GameSettings::readFile(QTextStream &stream)
|
||||||
mSettings.remove(key);
|
mSettings.remove(key);
|
||||||
|
|
||||||
QStringList values = cache.values(key);
|
QStringList values = cache.values(key);
|
||||||
|
values.append(mSettings.values(key));
|
||||||
|
|
||||||
if (!values.contains(value)) {
|
if (!values.contains(value)) {
|
||||||
cache.insertMulti(key, value);
|
cache.insertMulti(key, value);
|
||||||
}
|
}
|
||||||
|
@ -125,9 +144,16 @@ bool GameSettings::writeFile(QTextStream &stream)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Quote paths with spaces
|
// Quote paths with spaces
|
||||||
if (i.key() == QLatin1String("data")) {
|
if (i.key() == QLatin1String("data")
|
||||||
if (i.value().contains(" ")) {
|
|| i.key() == QLatin1String("data-local")
|
||||||
stream << i.key() << "=\"" << i.value() << "\"\n";
|
|| i.key() == QLatin1String("resources"))
|
||||||
|
{
|
||||||
|
if (i.value().contains(QChar(' ')))
|
||||||
|
{
|
||||||
|
QString stripped = i.value();
|
||||||
|
stripped.remove(QChar('\"')); // Remove quotes
|
||||||
|
|
||||||
|
stream << i.key() << "=\"" << stripped << "\"\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ bool LauncherSettings::writeFile(QTextStream &stream)
|
||||||
QString sectionPrefix;
|
QString sectionPrefix;
|
||||||
QRegExp sectionRe("([^/]+)/(.+)$");
|
QRegExp sectionRe("([^/]+)/(.+)$");
|
||||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||||
|
qDebug() << "writing " << settings;
|
||||||
|
|
||||||
QMapIterator<QString, QString> i(settings);
|
QMapIterator<QString, QString> i(settings);
|
||||||
i.toBack();
|
i.toBack();
|
||||||
|
@ -81,6 +82,13 @@ bool LauncherSettings::writeFile(QTextStream &stream)
|
||||||
key = sectionRe.cap(2);
|
key = sectionRe.cap(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get rid of legacy settings
|
||||||
|
if (key.contains(QChar('\\')))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (key == QLatin1String("CurrentProfile"))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (sectionPrefix != prefix) {
|
if (sectionPrefix != prefix) {
|
||||||
sectionPrefix = prefix;
|
sectionPrefix = prefix;
|
||||||
stream << "\n[" << prefix << "]\n";
|
stream << "\n[" << prefix << "]\n";
|
||||||
|
|
Loading…
Reference in a new issue