aboutsummaryrefslogtreecommitdiff
path: root/launcher/settings
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-06-18 23:27:41 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-06-18 23:27:41 +0300
commit6826f1d6051653bce8f670474d539a348b20e6d9 (patch)
tree824350062460ef21b223105c50165e6df7983954 /launcher/settings
parent0161520b332f485483f57acc305ad71a00d63fbc (diff)
parent12cd8a7bea991c2a8d4b59b1cfc9f7c246819fc9 (diff)
downloadPrismLauncher-6826f1d6051653bce8f670474d539a348b20e6d9.tar.gz
PrismLauncher-6826f1d6051653bce8f670474d539a348b20e6d9.tar.bz2
PrismLauncher-6826f1d6051653bce8f670474d539a348b20e6d9.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into net_job_crash
Diffstat (limited to 'launcher/settings')
-rw-r--r--launcher/settings/INIFile.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/launcher/settings/INIFile.cpp b/launcher/settings/INIFile.cpp
index cb909ae7..d16256b9 100644
--- a/launcher/settings/INIFile.cpp
+++ b/launcher/settings/INIFile.cpp
@@ -50,7 +50,7 @@ INIFile::INIFile() {}
bool INIFile::saveFile(QString fileName)
{
if (!contains("ConfigVersion"))
- insert("ConfigVersion", "1.1");
+ insert("ConfigVersion", "1.2");
QSettings _settings_obj{ fileName, QSettings::Format::IniFormat };
_settings_obj.setFallbacksEnabled(false);
@@ -97,6 +97,20 @@ QString unescape(QString orig)
}
return out;
}
+
+QString unquote(QString str)
+{
+ if ((str.contains(QChar(';')) || str.contains(QChar('=')) || str.contains(QChar(','))) && str.endsWith("\"") && str.startsWith("\"")) {
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
+ str = str.remove(0, 1);
+ str = str.remove(str.size() - 1, 1);
+#else
+ str = str.removeFirst().removeLast();
+#endif
+ }
+ return str;
+}
+
bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map)
{
QTextStream in(device.readAll());
@@ -124,7 +138,7 @@ bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map)
QString key = line.left(eqPos).trimmed();
QString valueStr = line.right(line.length() - eqPos - 1).trimmed();
- valueStr = unescape(valueStr);
+ valueStr = unquote(unescape(valueStr));
QVariant value(valueStr);
map.insert(key, value);
@@ -154,7 +168,17 @@ bool INIFile::loadFile(QString fileName)
file.close();
for (auto&& key : map.keys())
insert(key, map.value(key));
- insert("ConfigVersion", "1.1");
+ insert("ConfigVersion", "1.2");
+ } else if (_settings_obj.value("ConfigVersion").toString() == "1.1") {
+ for (auto&& key : _settings_obj.allKeys()) {
+ if (auto valueStr = _settings_obj.value(key).toString();
+ (valueStr.contains(QChar(';')) || valueStr.contains(QChar('=')) || valueStr.contains(QChar(','))) &&
+ valueStr.endsWith("\"") && valueStr.startsWith("\"")) {
+ insert(key, unquote(valueStr));
+ } else
+ insert(key, _settings_obj.value(key));
+ }
+ insert("ConfigVersion", "1.2");
} else
for (auto&& key : _settings_obj.allKeys())
insert(key, _settings_obj.value(key));