mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-30 15:50:17 -05:00
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:
parent
94eb3ffa7a
commit
413eec9b8c
8 changed files with 339 additions and 141 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue