Refactor Config.

Replaces all string configuration options with enum types
that can be checked by the compiler. This prevents spelling
errors, in-place configuration definitions, and inconsistent
default values. The default value config getter signature was
removed in favour of consistently and centrally default-initialised
configuration values.

Individual default values were adjusted for better security,
such as the default password length, which was increased from
16 characters to 32.

The already existing config option deprecation map was extended
by a general migration procedure using configuration versioning.

Settings were split into Roaming and Local settings, which
go to their respective AppData locations on Windows.

Fixes #2574
Fixes #2193
This commit is contained in:
Janek Bevendorff
2020-04-26 01:31:38 +02:00
parent 5add01243d
commit 596d2cf425
45 changed files with 1002 additions and 638 deletions

View File

@@ -99,14 +99,14 @@ void TestGui::initTestCase()
QVERIFY(Crypto::init());
Config::createTempFileInstance();
// Disable autosave so we can test the modified file indicator
config()->set("AutoSaveAfterEveryChange", false);
config()->set("AutoSaveOnExit", false);
config()->set(Config::AutoSaveAfterEveryChange, false);
config()->set(Config::AutoSaveOnExit, false);
// Enable the tray icon so we can test hiding/restoring the windowQByteArray
config()->set("GUI/ShowTrayIcon", true);
config()->set(Config::GUI_ShowTrayIcon, true);
// Disable advanced settings mode (activate within individual tests to test advanced settings)
config()->set("GUI/AdvancedSettings", false);
config()->set(Config::GUI_AdvancedSettings, false);
// Disable the update check first time alert
config()->set("UpdateCheckMessageShown", true);
config()->set(Config::UpdateCheckMessageShown, true);
Bootstrap::bootstrapApplication();
@@ -342,7 +342,7 @@ void TestGui::testMergeDatabase()
void TestGui::testAutoreloadDatabase()
{
config()->set("AutoReloadOnChange", false);
config()->set(Config::AutoReloadOnChange, false);
// Test accepting new file in autoreload
MessageBox::setNextAnswer(MessageBox::Yes);
@@ -375,7 +375,7 @@ void TestGui::testAutoreloadDatabase()
// Test accepting a merge of edits into autoreload
// Turn on autoload so we only get one messagebox (for the merge)
config()->set("AutoReloadOnChange", true);
config()->set(Config::AutoReloadOnChange, true);
// Modify some entries
testEditEntry();

View File

@@ -69,14 +69,14 @@ void TestGuiBrowser::initTestCase()
QVERIFY(Crypto::init());
Config::createTempFileInstance();
// Disable autosave so we can test the modified file indicator
config()->set("AutoSaveAfterEveryChange", false);
config()->set("AutoSaveOnExit", false);
config()->set(Config::AutoSaveAfterEveryChange, false);
config()->set(Config::AutoSaveOnExit, false);
// Enable the tray icon so we can test hiding/restoring the windowQByteArray
config()->set("GUI/ShowTrayIcon", true);
config()->set(Config::GUI_ShowTrayIcon, true);
// Disable advanced settings mode (activate within individual tests to test advanced settings)
config()->set("GUI/AdvancedSettings", false);
config()->set(Config::GUI_AdvancedSettings, false);
// Disable the update check first time alert
config()->set("UpdateCheckMessageShown", true);
config()->set(Config::UpdateCheckMessageShown, true);
m_mainWindow.reset(new MainWindow());
Bootstrap::restoreMainWindowState(*m_mainWindow);
@@ -146,7 +146,7 @@ void TestGuiBrowser::cleanupTestCase()
void TestGuiBrowser::testEntrySettings()
{
// Enable the Browser Integration
config()->set("Browser/Enabled", true);
config()->set(Config::Browser_Enabled, true);
auto* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
auto* entryView = m_dbWidget->findChild<EntryView*>("entryView");