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

@ -100,7 +100,7 @@ namespace Bootstrap
void restoreMainWindowState(MainWindow& mainWindow)
{
// start minimized if configured
if (config()->get("GUI/MinimizeOnStartup").toBool()) {
if (config()->get(Config::GUI_MinimizeOnStartup).toBool()) {
#ifdef Q_OS_WIN
mainWindow.showMinimized();
#else
@ -110,14 +110,14 @@ namespace Bootstrap
mainWindow.bringToFront();
}
if (config()->get("OpenPreviousDatabasesOnStartup").toBool()) {
const QStringList fileNames = config()->get("LastOpenedDatabases").toStringList();
if (config()->get(Config::OpenPreviousDatabasesOnStartup).toBool()) {
const QStringList fileNames = config()->get(Config::LastOpenedDatabases).toStringList();
for (const QString& filename : fileNames) {
if (!filename.isEmpty() && QFile::exists(filename)) {
mainWindow.openDatabase(filename);
}
}
auto lastActiveFile = config()->get("LastActiveDatabase").toString();
auto lastActiveFile = config()->get(Config::LastActiveDatabase).toString();
if (!lastActiveFile.isEmpty()) {
mainWindow.openDatabase(lastActiveFile);
}