diff --git a/src/ui/fortsettings.cpp b/src/ui/fortsettings.cpp index 8f9db4d9..300a304c 100644 --- a/src/ui/fortsettings.cpp +++ b/src/ui/fortsettings.cpp @@ -105,7 +105,7 @@ void FortSettings::setupGlobal() // Is portable? g_isPortable = FileUtil::fileExists(appFileInfo.path() + "/README.portable"); - // Use global settings from program's binary directory + // Global settings from program's binary directory const QSettings settings(appFileInfo.filePath() + ".ini", QSettings::IniFormat); // High-DPI scale factor rounding policy diff --git a/src/ui/user/iniuser.cpp b/src/ui/user/iniuser.cpp index 78aa0d8d..ea9fa3d0 100644 --- a/src/ui/user/iniuser.cpp +++ b/src/ui/user/iniuser.cpp @@ -2,12 +2,9 @@ IniUser::IniUser(Settings *settings) : MapSettings(settings) { } -void IniUser::setDefaultLanguage(const QString &v) +void IniUser::saveDefaultIni() { - m_defaultLanguage = v; + setLanguage(defaultLanguage()); - if (language().isEmpty()) { - setLanguage(defaultLanguage()); - save(); - } + save(); } diff --git a/src/ui/user/iniuser.h b/src/ui/user/iniuser.h index 1e289a0d..ddf546ff 100644 --- a/src/ui/user/iniuser.h +++ b/src/ui/user/iniuser.h @@ -9,7 +9,7 @@ public: explicit IniUser(Settings *settings = nullptr); QString defaultLanguage() const { return m_defaultLanguage; } - void setDefaultLanguage(const QString &v); + void setDefaultLanguage(const QString &v) { m_defaultLanguage = v; } QString language() const { return valueText("base/language"); } void setLanguage(const QString &v) { setValue("base/language", v); } @@ -194,6 +194,9 @@ public: bool statShowHostNames() const { return valueBool("statWindow/showHostNames"); } void setStatShowHostNames(bool on) { setValue("statWindow/showHostNames", on); } +public: + void saveDefaultIni(); + private: QString m_defaultLanguage; }; diff --git a/src/ui/user/usersettings.cpp b/src/ui/user/usersettings.cpp index 174da976..8b92825e 100644 --- a/src/ui/user/usersettings.cpp +++ b/src/ui/user/usersettings.cpp @@ -18,10 +18,17 @@ void UserSettings::setUp() void UserSettings::migrateIniOnStartup() { + if (!iniExists()) { + iniUser().saveDefaultIni(); + return; + } + int version; if (checkIniVersion(version)) return; + Settings::migrateIniOnStartup(); + // COMPAT: v3.4.0: .ini ~> .user.ini if (version < 0x030400) { setCacheValue("statWindow/trafUnit", ini()->value("stat/trafUnit"));