Add Import/Export to application settings

* Closes #9452 - add import/export buttons to application settings

* Fixes #11120 - duplicate both menubar and toolbar visibility settings into the application settings

* Fixes #8561 - improve placement of various settings between General and Security pages

* Improve tool tip for backup database setting
* Improve wording of various settings
This commit is contained in:
Jonathan White 2024-10-07 17:49:58 -04:00
parent 94eb3ffa7a
commit 413eec9b8c
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
8 changed files with 339 additions and 141 deletions

View file

@ -302,6 +302,45 @@ void Config::resetToDefaults()
}
}
bool Config::importSettings(const QString& fileName)
{
// Ensure file is valid ini with values
QSettings settings(fileName, QSettings::IniFormat);
if (settings.status() != QSettings::NoError || settings.allKeys().isEmpty()) {
return false;
}
// Only import valid roaming settings
auto isValidSetting = [](const QString& key) {
for (const auto& value : configStrings.values()) {
if (value.type == ConfigType::Roaming && value.name == key) {
return true;
}
}
return false;
};
// Clear existing settings and set valid items
m_settings->clear();
for (const auto& key : settings.allKeys()) {
if (isValidSetting(key)) {
m_settings->setValue(key, settings.value(key));
}
}
sync();
return true;
}
void Config::exportSettings(const QString& fileName) const
{
QSettings settings(fileName, QSettings::IniFormat);
for (const auto& key : m_settings->allKeys()) {
settings.setValue(key, m_settings->value(key));
}
}
/**
* Map of configuration file settings that are either deprecated, or have
* had their name changed to their new config enum values.