2011-12-25 18:17:40 +00:00
|
|
|
/*
|
2024-03-06 12:42:01 +00:00
|
|
|
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
|
2011-12-25 18:17:40 +00:00
|
|
|
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
|
* version 3 of the License.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef KEEPASSX_CONFIG_H
|
|
|
|
|
#define KEEPASSX_CONFIG_H
|
|
|
|
|
|
2020-03-09 02:45:51 +00:00
|
|
|
#include <QPointer>
|
2013-10-03 13:18:16 +00:00
|
|
|
#include <QVariant>
|
2024-02-04 11:29:04 +00:00
|
|
|
#include <QVector>
|
2011-12-25 18:17:40 +00:00
|
|
|
|
|
|
|
|
class QSettings;
|
|
|
|
|
|
2012-06-14 20:55:25 +00:00
|
|
|
class Config : public QObject
|
2011-12-25 18:17:40 +00:00
|
|
|
{
|
2018-03-31 20:01:30 +00:00
|
|
|
Q_OBJECT
|
2012-06-14 20:55:25 +00:00
|
|
|
|
2011-12-25 18:17:40 +00:00
|
|
|
public:
|
2018-02-04 12:18:59 +00:00
|
|
|
Q_DISABLE_COPY(Config)
|
|
|
|
|
|
2020-04-25 23:31:38 +00:00
|
|
|
enum ConfigKey
|
|
|
|
|
{
|
|
|
|
|
SingleInstance,
|
|
|
|
|
RememberLastDatabases,
|
|
|
|
|
NumberOfRememberedLastDatabases,
|
|
|
|
|
RememberLastKeyFiles,
|
|
|
|
|
OpenPreviousDatabasesOnStartup,
|
|
|
|
|
AutoSaveAfterEveryChange,
|
|
|
|
|
AutoReloadOnChange,
|
|
|
|
|
AutoSaveOnExit,
|
2020-08-01 22:00:47 +00:00
|
|
|
AutoSaveNonDataChanges,
|
2020-04-25 23:31:38 +00:00
|
|
|
BackupBeforeSave,
|
2021-11-07 22:41:17 +00:00
|
|
|
BackupFilePathPattern,
|
2020-04-25 23:31:38 +00:00
|
|
|
UseAtomicSaves,
|
2021-10-01 20:56:49 +00:00
|
|
|
UseDirectWriteSaves,
|
2020-04-25 23:31:38 +00:00
|
|
|
SearchLimitGroup,
|
|
|
|
|
MinimizeOnOpenUrl,
|
2024-10-09 10:42:33 +00:00
|
|
|
OpenURLOnDoubleClick,
|
2020-04-25 23:31:38 +00:00
|
|
|
HideWindowOnCopy,
|
|
|
|
|
MinimizeOnCopy,
|
|
|
|
|
MinimizeAfterUnlock,
|
|
|
|
|
DropToBackgroundOnCopy,
|
|
|
|
|
UseGroupIconOnEntryCreation,
|
|
|
|
|
AutoTypeEntryTitleMatch,
|
|
|
|
|
AutoTypeEntryURLMatch,
|
|
|
|
|
AutoTypeDelay,
|
|
|
|
|
AutoTypeStartDelay,
|
2020-08-29 12:44:50 +00:00
|
|
|
AutoTypeHideExpiredEntry,
|
2023-06-01 17:42:25 +00:00
|
|
|
AutoTypeDialogSortColumn,
|
|
|
|
|
AutoTypeDialogSortOrder,
|
2020-04-25 23:31:38 +00:00
|
|
|
GlobalAutoTypeKey,
|
|
|
|
|
GlobalAutoTypeModifiers,
|
2022-02-19 20:40:59 +00:00
|
|
|
GlobalAutoTypeRetypeTime,
|
2020-04-25 23:31:38 +00:00
|
|
|
FaviconDownloadTimeout,
|
|
|
|
|
UpdateCheckMessageShown,
|
2022-05-12 10:19:20 +00:00
|
|
|
DefaultDatabaseFileName,
|
2020-04-25 23:31:38 +00:00
|
|
|
|
|
|
|
|
LastDatabases,
|
|
|
|
|
LastKeyFiles,
|
|
|
|
|
LastChallengeResponse,
|
|
|
|
|
LastActiveDatabase,
|
|
|
|
|
LastOpenedDatabases,
|
|
|
|
|
LastDir,
|
|
|
|
|
|
|
|
|
|
GUI_Language,
|
2024-04-28 02:09:38 +00:00
|
|
|
GUI_HideMenubar,
|
2020-04-25 23:31:38 +00:00
|
|
|
GUI_HideToolbar,
|
|
|
|
|
GUI_MovableToolbar,
|
2024-09-23 01:23:54 +00:00
|
|
|
GUI_HideGroupPanel,
|
2020-04-25 23:31:38 +00:00
|
|
|
GUI_HidePreviewPanel,
|
2021-03-06 18:29:08 +00:00
|
|
|
GUI_AlwaysOnTop,
|
2020-04-25 23:31:38 +00:00
|
|
|
GUI_ToolButtonStyle,
|
2024-04-07 22:10:19 +00:00
|
|
|
GUI_LaunchAtStartup,
|
2020-04-25 23:31:38 +00:00
|
|
|
GUI_ShowTrayIcon,
|
2020-05-30 20:46:06 +00:00
|
|
|
GUI_TrayIconAppearance,
|
2020-04-25 23:31:38 +00:00
|
|
|
GUI_MinimizeToTray,
|
|
|
|
|
GUI_MinimizeOnStartup,
|
|
|
|
|
GUI_MinimizeOnClose,
|
|
|
|
|
GUI_HideUsernames,
|
2020-10-12 00:07:00 +00:00
|
|
|
GUI_HidePasswords,
|
2022-10-02 13:44:50 +00:00
|
|
|
GUI_ColorPasswords,
|
2020-04-25 23:31:38 +00:00
|
|
|
GUI_MonospaceNotes,
|
|
|
|
|
GUI_ApplicationTheme,
|
2020-06-28 12:26:02 +00:00
|
|
|
GUI_CompactMode,
|
2020-04-25 23:31:38 +00:00
|
|
|
GUI_CheckForUpdates,
|
|
|
|
|
GUI_CheckForUpdatesIncludeBetas,
|
2022-01-22 18:20:41 +00:00
|
|
|
GUI_ShowExpiredEntriesOnDatabaseUnlock,
|
|
|
|
|
GUI_ShowExpiredEntriesOnDatabaseUnlockOffsetDays,
|
2024-12-15 23:58:07 +00:00
|
|
|
GUI_FontSizeOffset,
|
2020-04-25 23:31:38 +00:00
|
|
|
|
|
|
|
|
GUI_MainWindowGeometry,
|
|
|
|
|
GUI_MainWindowState,
|
|
|
|
|
GUI_ListViewState,
|
|
|
|
|
GUI_SearchViewState,
|
|
|
|
|
GUI_PreviewSplitterState,
|
|
|
|
|
GUI_SplitterState,
|
2022-01-23 15:00:48 +00:00
|
|
|
GUI_GroupSplitterState,
|
2020-04-25 23:31:38 +00:00
|
|
|
GUI_AutoTypeSelectDialogSize,
|
|
|
|
|
GUI_CheckForUpdatesNextCheck,
|
|
|
|
|
|
|
|
|
|
Security_ClearClipboard,
|
|
|
|
|
Security_ClearClipboardTimeout,
|
|
|
|
|
Security_ClearSearch,
|
|
|
|
|
Security_ClearSearchTimeout,
|
|
|
|
|
Security_HideNotes,
|
|
|
|
|
Security_LockDatabaseIdle,
|
|
|
|
|
Security_LockDatabaseIdleSeconds,
|
|
|
|
|
Security_LockDatabaseMinimize,
|
|
|
|
|
Security_LockDatabaseScreenLock,
|
2024-08-11 22:32:10 +00:00
|
|
|
Security_LockDatabaseOnUserSwitch,
|
2020-04-25 23:31:38 +00:00
|
|
|
Security_RelockAutoType,
|
2020-05-11 01:35:08 +00:00
|
|
|
Security_PasswordsHidden,
|
|
|
|
|
Security_PasswordEmptyPlaceholder,
|
2020-04-25 23:31:38 +00:00
|
|
|
Security_HidePasswordPreviewPanel,
|
2023-02-26 20:21:23 +00:00
|
|
|
Security_HideTotpPreviewPanel,
|
2020-04-25 23:31:38 +00:00
|
|
|
Security_AutoTypeAsk,
|
|
|
|
|
Security_IconDownloadFallback,
|
2020-12-12 17:14:18 +00:00
|
|
|
Security_NoConfirmMoveEntryToRecycleBin,
|
2021-04-24 15:35:01 +00:00
|
|
|
Security_EnableCopyOnDoubleClick,
|
2022-02-22 01:40:01 +00:00
|
|
|
Security_QuickUnlock,
|
2024-01-06 18:53:18 +00:00
|
|
|
Security_DatabasePasswordMinimumQuality,
|
2020-04-25 23:31:38 +00:00
|
|
|
|
|
|
|
|
Browser_Enabled,
|
|
|
|
|
Browser_ShowNotification,
|
|
|
|
|
Browser_BestMatchOnly,
|
|
|
|
|
Browser_UnlockDatabase,
|
|
|
|
|
Browser_MatchUrlScheme,
|
|
|
|
|
Browser_SupportBrowserProxy,
|
|
|
|
|
Browser_UseCustomProxy,
|
|
|
|
|
Browser_CustomProxyLocation,
|
|
|
|
|
Browser_UpdateBinaryPath,
|
2023-02-25 19:09:36 +00:00
|
|
|
Browser_AllowGetDatabaseEntriesRequest,
|
2020-04-25 23:31:38 +00:00
|
|
|
Browser_AllowExpiredCredentials,
|
|
|
|
|
Browser_AlwaysAllowAccess,
|
|
|
|
|
Browser_AlwaysAllowUpdate,
|
|
|
|
|
Browser_HttpAuthPermission,
|
|
|
|
|
Browser_SearchInAllDatabases,
|
|
|
|
|
Browser_SupportKphFields,
|
|
|
|
|
Browser_NoMigrationPrompt,
|
2020-05-17 19:44:52 +00:00
|
|
|
Browser_UseCustomBrowser,
|
|
|
|
|
Browser_CustomBrowserType,
|
|
|
|
|
Browser_CustomBrowserLocation,
|
2024-03-06 12:42:01 +00:00
|
|
|
Browser_AllowLocalhostWithPasskeys,
|
2020-04-12 15:51:46 +00:00
|
|
|
#ifdef QT_DEBUG
|
|
|
|
|
Browser_CustomExtensionId,
|
|
|
|
|
#endif
|
2020-04-25 23:31:38 +00:00
|
|
|
|
|
|
|
|
SSHAgent_Enabled,
|
|
|
|
|
SSHAgent_UseOpenSSH,
|
2021-04-03 15:23:09 +00:00
|
|
|
SSHAgent_UsePageant,
|
2020-04-25 23:31:38 +00:00
|
|
|
SSHAgent_AuthSockOverride,
|
2020-02-16 12:44:18 +00:00
|
|
|
SSHAgent_SecurityKeyProviderOverride,
|
2020-04-25 23:31:38 +00:00
|
|
|
|
|
|
|
|
FdoSecrets_Enabled,
|
|
|
|
|
FdoSecrets_ShowNotification,
|
2021-02-05 20:07:59 +00:00
|
|
|
FdoSecrets_ConfirmDeleteItem,
|
|
|
|
|
FdoSecrets_ConfirmAccessItem,
|
2021-09-18 23:55:37 +00:00
|
|
|
FdoSecrets_UnlockBeforeSearch,
|
2020-04-25 23:31:38 +00:00
|
|
|
|
|
|
|
|
KeeShare_QuietSuccess,
|
|
|
|
|
KeeShare_Own,
|
|
|
|
|
KeeShare_Foreign,
|
|
|
|
|
KeeShare_Active,
|
|
|
|
|
|
|
|
|
|
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,
|
2020-05-15 18:17:40 +00:00
|
|
|
Messages_HidePreReleaseWarning,
|
2020-04-25 23:31:38 +00:00
|
|
|
|
|
|
|
|
// Special internal value
|
|
|
|
|
Deleted
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-04 11:29:04 +00:00
|
|
|
struct ShortcutEntry
|
|
|
|
|
{
|
|
|
|
|
QString name;
|
|
|
|
|
QString shortcut;
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-04 12:18:59 +00:00
|
|
|
~Config() override;
|
2020-04-25 23:31:38 +00:00
|
|
|
QVariant get(ConfigKey key);
|
2021-11-07 22:41:17 +00:00
|
|
|
QVariant getDefault(ConfigKey key);
|
2017-03-06 22:12:07 +00:00
|
|
|
QString getFileName();
|
2020-04-25 23:31:38 +00:00
|
|
|
void set(ConfigKey key, const QVariant& value);
|
|
|
|
|
void remove(ConfigKey key);
|
2017-03-06 22:12:07 +00:00
|
|
|
bool hasAccessError();
|
2018-02-04 12:18:59 +00:00
|
|
|
void sync();
|
2019-08-31 00:18:41 +00:00
|
|
|
void resetToDefaults();
|
2011-12-25 18:17:40 +00:00
|
|
|
|
2024-10-05 15:22:10 +00:00
|
|
|
bool importSettings(const QString& fileName);
|
|
|
|
|
void exportSettings(const QString& fileName) const;
|
|
|
|
|
|
2024-02-04 11:29:04 +00:00
|
|
|
QList<ShortcutEntry> getShortcuts() const;
|
|
|
|
|
void setShortcuts(const QList<ShortcutEntry>& shortcuts);
|
|
|
|
|
|
2012-05-31 12:51:44 +00:00
|
|
|
static Config* instance();
|
2020-09-20 13:39:59 +00:00
|
|
|
static void createConfigFromFile(const QString& configFileName, const QString& localConfigFileName = {});
|
2024-05-26 14:19:10 +00:00
|
|
|
static bool isPortable();
|
|
|
|
|
static QString portableConfigDir();
|
2012-05-31 12:51:44 +00:00
|
|
|
|
2018-10-01 14:26:24 +00:00
|
|
|
signals:
|
2020-04-25 23:31:38 +00:00
|
|
|
void changed(ConfigKey key);
|
2018-10-01 14:26:24 +00:00
|
|
|
|
2011-12-25 18:17:40 +00:00
|
|
|
private:
|
2020-09-20 13:39:59 +00:00
|
|
|
Config(const QString& configFileName, const QString& localConfigFileName, QObject* parent);
|
2012-06-24 09:32:54 +00:00
|
|
|
explicit Config(QObject* parent);
|
2020-09-20 13:39:59 +00:00
|
|
|
void init(const QString& configFileName, const QString& localConfigFileName);
|
2020-04-25 23:31:38 +00:00
|
|
|
void migrate();
|
2020-09-20 13:39:59 +00:00
|
|
|
static QPair<QString, QString> defaultConfigFiles();
|
2011-12-25 18:17:40 +00:00
|
|
|
|
2020-03-09 02:45:51 +00:00
|
|
|
static QPointer<Config> m_instance;
|
2012-05-31 12:51:44 +00:00
|
|
|
|
2012-04-23 17:44:43 +00:00
|
|
|
QScopedPointer<QSettings> m_settings;
|
2020-04-25 23:31:38 +00:00
|
|
|
QScopedPointer<QSettings> m_localSettings;
|
2012-05-27 18:05:57 +00:00
|
|
|
QHash<QString, QVariant> m_defaults;
|
2011-12-25 18:17:40 +00:00
|
|
|
};
|
|
|
|
|
|
2018-03-31 20:01:30 +00:00
|
|
|
inline Config* config()
|
|
|
|
|
{
|
2012-05-31 12:51:44 +00:00
|
|
|
return Config::instance();
|
|
|
|
|
}
|
2011-12-25 18:17:40 +00:00
|
|
|
|
|
|
|
|
#endif // KEEPASSX_CONFIG_H
|