mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-17 17:34:50 -05:00
Create config file deprecation mechanism & rename Details->Preview (#2371)
Rename UI elements involved with the bottom preview panel to use the terminology "entry preview panel" instead of "details view" or "preview panel". Change all associated variables, widgets, and classes to reference EntryPreviewPanel. Create Config::upgrade() function and deprecation mapping to help rename/remove previous config settings in a clean manner. Fixes #2327
This commit is contained in:
parent
4ff63c2bf5
commit
265325057a
13 changed files with 109 additions and 77 deletions
|
|
@ -24,6 +24,23 @@
|
|||
#include <QStandardPaths>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
/*
|
||||
* Map of configuration file settings that are either deprecated, or have
|
||||
* had their name changed. Entries in the map are of the form
|
||||
* {oldName, newName}
|
||||
* Set newName to empty string to remove the setting from the file.
|
||||
*/
|
||||
static const QMap<QString, QString> deprecationMap = {
|
||||
// >2.3.4
|
||||
{"security/hidepassworddetails", "security/HidePasswordPreviewPanel"},
|
||||
// >2.3.4
|
||||
{"GUI/HideDetailsView", "GUI/HidePreviewPanel"},
|
||||
// >2.3.4
|
||||
{"GUI/DetailSplitterState", "GUI/PreviewSplitterState"},
|
||||
// >2.3.4
|
||||
{"security/IconDownloadFallbackToGoogle", "security/IconDownloadFallback"},
|
||||
};
|
||||
|
||||
Config* Config::m_instance(nullptr);
|
||||
|
||||
QVariant Config::get(const QString& key)
|
||||
|
|
@ -63,6 +80,19 @@ void Config::sync()
|
|||
m_settings->sync();
|
||||
}
|
||||
|
||||
void Config::upgrade()
|
||||
{
|
||||
for (const auto& setting : deprecationMap.keys()) {
|
||||
if (m_settings->contains(setting)) {
|
||||
if(!deprecationMap.value(setting).isEmpty()) {
|
||||
// Add entry with new name and old entry's value
|
||||
m_settings->setValue(deprecationMap.value(setting), m_settings->value(setting));
|
||||
}
|
||||
m_settings->remove(setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Config::Config(const QString& fileName, QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
|
@ -118,6 +148,7 @@ Config::~Config()
|
|||
void Config::init(const QString& fileName)
|
||||
{
|
||||
m_settings.reset(new QSettings(fileName, QSettings::IniFormat));
|
||||
upgrade();
|
||||
connect(qApp, &QCoreApplication::aboutToQuit, this, &Config::sync);
|
||||
|
||||
m_defaults.insert("SingleInstance", true);
|
||||
|
|
@ -147,7 +178,7 @@ void Config::init(const QString& fileName)
|
|||
m_defaults.insert("security/passwordsrepeat", false);
|
||||
m_defaults.insert("security/passwordscleartext", false);
|
||||
m_defaults.insert("security/passwordemptynodots", true);
|
||||
m_defaults.insert("security/hidepassworddetails", true);
|
||||
m_defaults.insert("security/HidePasswordPreviewPanel", true);
|
||||
m_defaults.insert("security/autotypeask", true);
|
||||
m_defaults.insert("security/IconDownloadFallback", false);
|
||||
m_defaults.insert("security/resettouchid", false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue