mirror of
https://github.com/tnodir/fort
synced 2024-11-15 05:57:57 +00:00
UI: IniUser: Refactor saving initial ini
This commit is contained in:
parent
5850d4e58c
commit
fe21129c4e
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user