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:
@@ -42,7 +42,7 @@ UpdateChecker::~UpdateChecker()
|
||||
|
||||
void UpdateChecker::checkForUpdates(bool manuallyRequested)
|
||||
{
|
||||
auto nextCheck = config()->get("GUI/CheckForUpdatesNextCheck", 0).toULongLong();
|
||||
auto nextCheck = config()->get(Config::GUI_CheckForUpdatesNextCheck).toULongLong();
|
||||
m_isManuallyRequested = manuallyRequested;
|
||||
|
||||
if (m_isManuallyRequested || Clock::currentSecondsSinceEpoch() >= nextCheck) {
|
||||
@@ -50,7 +50,7 @@ void UpdateChecker::checkForUpdates(bool manuallyRequested)
|
||||
|
||||
QString apiUrlStr = QString("https://api.github.com/repos/keepassxreboot/keepassxc/releases");
|
||||
|
||||
if (!config()->get("GUI/CheckForUpdatesIncludeBetas", false).toBool()) {
|
||||
if (!config()->get(Config::GUI_CheckForUpdatesIncludeBetas).toBool()) {
|
||||
apiUrlStr += "/latest";
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void UpdateChecker::fetchFinished()
|
||||
QJsonDocument jsonResponse = QJsonDocument::fromJson(m_bytesReceived);
|
||||
QJsonObject jsonObject = jsonResponse.object();
|
||||
|
||||
if (config()->get("GUI/CheckForUpdatesIncludeBetas", false).toBool()) {
|
||||
if (config()->get(Config::GUI_CheckForUpdatesIncludeBetas).toBool()) {
|
||||
QJsonArray jsonArray = jsonResponse.array();
|
||||
jsonObject = jsonArray.at(0).toObject();
|
||||
}
|
||||
@@ -97,7 +97,7 @@ void UpdateChecker::fetchFinished()
|
||||
|
||||
// Check again in 7 days
|
||||
// TODO: change to toSecsSinceEpoch() when min Qt >= 5.8
|
||||
config()->set("GUI/CheckForUpdatesNextCheck", Clock::currentDateTime().addDays(7).toTime_t());
|
||||
config()->set(Config::GUI_CheckForUpdatesNextCheck, Clock::currentDateTime().addDays(7).toTime_t());
|
||||
} else {
|
||||
version = "error";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user