forked from mirror/openmw-tes3mp
Fix for duplicate key/value pairs being written to settings.cfg, Bug #755
This commit is contained in:
parent
512dcdc735
commit
b3595a6a2e
4 changed files with 31 additions and 16 deletions
|
@ -310,6 +310,8 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||||
|
|
||||||
bool MainDialog::setupLauncherSettings()
|
bool MainDialog::setupLauncherSettings()
|
||||||
{
|
{
|
||||||
|
mLauncherSettings.setMultiValueEnabled(true);
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||||
|
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
|
@ -427,6 +429,8 @@ bool MainDialog::setupGameSettings()
|
||||||
|
|
||||||
bool MainDialog::setupGraphicsSettings()
|
bool MainDialog::setupGraphicsSettings()
|
||||||
{
|
{
|
||||||
|
mGraphicsSettings.setMultiValueEnabled(false);
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||||
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,8 @@ bool GameSettings::readFile(QTextStream &stream)
|
||||||
|
|
||||||
if (keyRe.indexIn(line) != -1) {
|
if (keyRe.indexIn(line) != -1) {
|
||||||
|
|
||||||
QString key = keyRe.cap(1);
|
QString key = keyRe.cap(1).trimmed();
|
||||||
QString value = keyRe.cap(2);
|
QString value = keyRe.cap(2).trimmed();
|
||||||
|
|
||||||
// Don't remove existing data entries
|
// Don't remove existing data entries
|
||||||
if (key != QLatin1String("data"))
|
if (key != QLatin1String("data"))
|
||||||
|
|
|
@ -14,7 +14,7 @@ class SettingsBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SettingsBase() {}
|
SettingsBase() { mMultiValue = false; }
|
||||||
~SettingsBase() {}
|
~SettingsBase() {}
|
||||||
|
|
||||||
inline QString value(const QString &key, const QString &defaultValue = QString())
|
inline QString value(const QString &key, const QString &defaultValue = QString())
|
||||||
|
@ -36,6 +36,11 @@ public:
|
||||||
mSettings.insertMulti(key, value);
|
mSettings.insertMulti(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void setMultiValueEnabled(bool enable)
|
||||||
|
{
|
||||||
|
mMultiValue = enable;
|
||||||
|
}
|
||||||
|
|
||||||
inline void remove(const QString &key)
|
inline void remove(const QString &key)
|
||||||
{
|
{
|
||||||
mSettings.remove(key);
|
mSettings.remove(key);
|
||||||
|
@ -66,8 +71,8 @@ public:
|
||||||
|
|
||||||
if (keyRe.indexIn(line) != -1) {
|
if (keyRe.indexIn(line) != -1) {
|
||||||
|
|
||||||
QString key = keyRe.cap(1);
|
QString key = keyRe.cap(1).trimmed();
|
||||||
QString value = keyRe.cap(2);
|
QString value = keyRe.cap(2).trimmed();
|
||||||
|
|
||||||
if (!sectionPrefix.isEmpty())
|
if (!sectionPrefix.isEmpty())
|
||||||
key.prepend(sectionPrefix);
|
key.prepend(sectionPrefix);
|
||||||
|
@ -75,8 +80,13 @@ public:
|
||||||
mSettings.remove(key);
|
mSettings.remove(key);
|
||||||
|
|
||||||
QStringList values = mCache.values(key);
|
QStringList values = mCache.values(key);
|
||||||
|
|
||||||
if (!values.contains(value)) {
|
if (!values.contains(value)) {
|
||||||
mCache.insertMulti(key, value);
|
if (mMultiValue) {
|
||||||
|
mCache.insertMulti(key, value);
|
||||||
|
} else {
|
||||||
|
mCache.insert(key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +104,8 @@ public:
|
||||||
private:
|
private:
|
||||||
Map mSettings;
|
Map mSettings;
|
||||||
Map mCache;
|
Map mCache;
|
||||||
|
|
||||||
|
bool mMultiValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSBASE_HPP
|
#endif // SETTINGSBASE_HPP
|
||||||
|
|
|
@ -2,9 +2,17 @@
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>PlayPage</class>
|
<class>PlayPage</class>
|
||||||
<widget class="QWidget" name="PlayPage">
|
<widget class="QWidget" name="PlayPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>274</width>
|
||||||
|
<height>317</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="Scroll">
|
<widget class="QWidget" name="Scroll" native="true">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">#Scroll {
|
<string notr="true">#Scroll {
|
||||||
background-image: url(":/images/playpage-background.png");
|
background-image: url(":/images/playpage-background.png");
|
||||||
|
@ -13,15 +21,6 @@
|
||||||
}
|
}
|
||||||
</string>
|
</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
<property name="lineWidth">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>30</number>
|
<number>30</number>
|
||||||
|
|
Loading…
Reference in a new issue