mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-19 14:32:26 -05:00
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:
parent
5add01243d
commit
596d2cf425
45 changed files with 1002 additions and 638 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
|
||||
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
|
||||
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -32,11 +32,160 @@ class Config : public QObject
|
|||
public:
|
||||
Q_DISABLE_COPY(Config)
|
||||
|
||||
enum ConfigKey
|
||||
{
|
||||
SingleInstance,
|
||||
RememberLastDatabases,
|
||||
NumberOfRememberedLastDatabases,
|
||||
RememberLastKeyFiles,
|
||||
OpenPreviousDatabasesOnStartup,
|
||||
AutoSaveAfterEveryChange,
|
||||
AutoReloadOnChange,
|
||||
AutoSaveOnExit,
|
||||
BackupBeforeSave,
|
||||
UseAtomicSaves,
|
||||
SearchLimitGroup,
|
||||
MinimizeOnOpenUrl,
|
||||
HideWindowOnCopy,
|
||||
MinimizeOnCopy,
|
||||
MinimizeAfterUnlock,
|
||||
DropToBackgroundOnCopy,
|
||||
UseGroupIconOnEntryCreation,
|
||||
AutoTypeEntryTitleMatch,
|
||||
AutoTypeEntryURLMatch,
|
||||
AutoTypeDelay,
|
||||
AutoTypeStartDelay,
|
||||
GlobalAutoTypeKey,
|
||||
GlobalAutoTypeModifiers,
|
||||
IgnoreGroupExpansion,
|
||||
FaviconDownloadTimeout,
|
||||
UpdateCheckMessageShown,
|
||||
UseTouchID,
|
||||
|
||||
LastDatabases,
|
||||
LastKeyFiles,
|
||||
LastChallengeResponse,
|
||||
LastActiveDatabase,
|
||||
LastOpenedDatabases,
|
||||
LastDir,
|
||||
LastAttachmentDir,
|
||||
|
||||
GUI_Language,
|
||||
GUI_HideToolbar,
|
||||
GUI_MovableToolbar,
|
||||
GUI_HidePreviewPanel,
|
||||
GUI_ToolButtonStyle,
|
||||
GUI_ShowTrayIcon,
|
||||
GUI_DarkTrayIcon,
|
||||
GUI_MinimizeToTray,
|
||||
GUI_MinimizeOnStartup,
|
||||
GUI_MinimizeOnClose,
|
||||
GUI_HideUsernames,
|
||||
GUI_HidePasswords,
|
||||
GUI_AdvancedSettings,
|
||||
GUI_MonospaceNotes,
|
||||
GUI_ApplicationTheme,
|
||||
GUI_CheckForUpdates,
|
||||
GUI_CheckForUpdatesIncludeBetas,
|
||||
|
||||
GUI_MainWindowGeometry,
|
||||
GUI_MainWindowState,
|
||||
GUI_ListViewState,
|
||||
GUI_SearchViewState,
|
||||
GUI_PreviewSplitterState,
|
||||
GUI_SplitterState,
|
||||
GUI_AutoTypeSelectDialogSize,
|
||||
GUI_CheckForUpdatesNextCheck,
|
||||
|
||||
Security_ClearClipboard,
|
||||
Security_ClearClipboardTimeout,
|
||||
Security_ClearSearch,
|
||||
Security_ClearSearchTimeout,
|
||||
Security_HideNotes,
|
||||
Security_LockDatabaseIdle,
|
||||
Security_LockDatabaseIdleSeconds,
|
||||
Security_LockDatabaseMinimize,
|
||||
Security_LockDatabaseScreenLock,
|
||||
Security_RelockAutoType,
|
||||
Security_PasswordsRepeat,
|
||||
Security_PasswordsCleartext,
|
||||
Security_PasswordEmptyNoDots,
|
||||
Security_HidePasswordPreviewPanel,
|
||||
Security_AutoTypeAsk,
|
||||
Security_IconDownloadFallback,
|
||||
Security_ResetTouchId,
|
||||
Security_ResetTouchIdTimeout,
|
||||
Security_ResetTouchIdScreenlock,
|
||||
|
||||
Browser_Enabled,
|
||||
Browser_ShowNotification,
|
||||
Browser_BestMatchOnly,
|
||||
Browser_UnlockDatabase,
|
||||
Browser_MatchUrlScheme,
|
||||
Browser_SortByUsername,
|
||||
Browser_SupportBrowserProxy,
|
||||
Browser_UseCustomProxy,
|
||||
Browser_CustomProxyLocation,
|
||||
Browser_UpdateBinaryPath,
|
||||
Browser_AllowExpiredCredentials,
|
||||
Browser_AlwaysAllowAccess,
|
||||
Browser_AlwaysAllowUpdate,
|
||||
Browser_HttpAuthPermission,
|
||||
Browser_SearchInAllDatabases,
|
||||
Browser_SupportKphFields,
|
||||
Browser_NoMigrationPrompt,
|
||||
|
||||
SSHAgent_Enabled,
|
||||
SSHAgent_UseOpenSSH,
|
||||
SSHAgent_AuthSockOverride,
|
||||
|
||||
FdoSecrets_Enabled,
|
||||
FdoSecrets_ShowNotification,
|
||||
FdoSecrets_NoConfirmDeleteItem,
|
||||
|
||||
KeeShare_QuietSuccess,
|
||||
KeeShare_Own,
|
||||
KeeShare_Foreign,
|
||||
KeeShare_Active,
|
||||
KeeShare_LastDir,
|
||||
KeeShare_LastKeyDir,
|
||||
KeeShare_LastShareDir,
|
||||
|
||||
PasswordGenerator_LowerCase,
|
||||
PasswordGenerator_UpperCase,
|
||||
PasswordGenerator_Numbers,
|
||||
PasswordGenerator_EASCII,
|
||||
PasswordGenerator_AdvancedMode,
|
||||
PasswordGenerator_SpecialChars,
|
||||
PasswordGenerator_AdditionalChars,
|
||||
PasswordGenerator_Braces,
|
||||
PasswordGenerator_Punctuation,
|
||||
PasswordGenerator_Quotes,
|
||||
PasswordGenerator_Dashes,
|
||||
PasswordGenerator_Math,
|
||||
PasswordGenerator_Logograms,
|
||||
PasswordGenerator_ExcludedChars,
|
||||
PasswordGenerator_ExcludeAlike,
|
||||
PasswordGenerator_EnsureEvery,
|
||||
PasswordGenerator_Length,
|
||||
PasswordGenerator_WordCount,
|
||||
PasswordGenerator_WordSeparator,
|
||||
PasswordGenerator_WordList,
|
||||
PasswordGenerator_WordCase,
|
||||
PasswordGenerator_Type,
|
||||
|
||||
Messages_NoLegacyKeyFileWarning,
|
||||
Messages_Qt55CompatibilityWarning,
|
||||
|
||||
// Special internal value
|
||||
Deleted
|
||||
};
|
||||
|
||||
~Config() override;
|
||||
QVariant get(const QString& key);
|
||||
QVariant get(const QString& key, const QVariant& defaultValue);
|
||||
QVariant get(ConfigKey key);
|
||||
QString getFileName();
|
||||
void set(const QString& key, const QVariant& value);
|
||||
void set(ConfigKey key, const QVariant& value);
|
||||
void remove(ConfigKey key);
|
||||
bool hasAccessError();
|
||||
void sync();
|
||||
void resetToDefaults();
|
||||
|
|
@ -46,17 +195,18 @@ public:
|
|||
static void createTempFileInstance();
|
||||
|
||||
signals:
|
||||
void changed(const QString& key);
|
||||
void changed(ConfigKey key);
|
||||
|
||||
private:
|
||||
Config(const QString& fileName, QObject* parent);
|
||||
Config(const QString& fileName, QObject* parent = nullptr);
|
||||
explicit Config(QObject* parent);
|
||||
void init(const QString& fileName);
|
||||
void upgrade();
|
||||
void init(const QString& configFileName, const QString& localConfigFileName = "");
|
||||
void migrate();
|
||||
|
||||
static QPointer<Config> m_instance;
|
||||
|
||||
QScopedPointer<QSettings> m_settings;
|
||||
QScopedPointer<QSettings> m_localSettings;
|
||||
QHash<QString, QVariant> m_defaults;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue