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:
@@ -35,7 +35,7 @@ QString FileDialog::getOpenFileName(QWidget* parent,
|
||||
m_nextFileName.clear();
|
||||
return result;
|
||||
} else {
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get("LastDir").toString() : dir;
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get(Config::LastDir).toString() : dir;
|
||||
const auto result = QDir::toNativeSeparators(
|
||||
QFileDialog::getOpenFileName(parent, caption, workingDir, filter, selectedFilter, options));
|
||||
|
||||
@@ -62,7 +62,7 @@ QStringList FileDialog::getOpenFileNames(QWidget* parent,
|
||||
m_nextFileNames.clear();
|
||||
return results;
|
||||
} else {
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get("LastDir").toString() : dir;
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get(Config::LastDir).toString() : dir;
|
||||
auto results = QFileDialog::getOpenFileNames(parent, caption, workingDir, filter, selectedFilter, options);
|
||||
|
||||
for (auto& path : results) {
|
||||
@@ -94,7 +94,7 @@ QString FileDialog::getFileName(QWidget* parent,
|
||||
m_nextFileName.clear();
|
||||
return result;
|
||||
} else {
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get("LastDir").toString() : dir;
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get(Config::LastDir).toString() : dir;
|
||||
const auto result = QDir::toNativeSeparators(
|
||||
QFileDialog::getSaveFileName(parent, caption, workingDir, filter, selectedFilter, options));
|
||||
|
||||
@@ -121,7 +121,7 @@ QString FileDialog::getSaveFileName(QWidget* parent,
|
||||
m_nextFileName.clear();
|
||||
return result;
|
||||
} else {
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get("LastDir").toString() : dir;
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get(Config::LastDir).toString() : dir;
|
||||
const auto result = QDir::toNativeSeparators(
|
||||
QFileDialog::getSaveFileName(parent, caption, workingDir, filter, selectedFilter, options));
|
||||
|
||||
@@ -146,7 +146,7 @@ QString FileDialog::getExistingDirectory(QWidget* parent,
|
||||
m_nextDirName.clear();
|
||||
return result;
|
||||
} else {
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get("LastDir").toString() : dir;
|
||||
const auto& workingDir = dir.isEmpty() ? config()->get(Config::LastDir).toString() : dir;
|
||||
const auto result =
|
||||
QDir::toNativeSeparators(QFileDialog::getExistingDirectory(parent, caption, workingDir, options));
|
||||
|
||||
@@ -188,7 +188,7 @@ FileDialog::FileDialog()
|
||||
void FileDialog::saveLastDir(const QString& dir)
|
||||
{
|
||||
if (!dir.isEmpty() && !m_forgetLastDir) {
|
||||
config()->set("LastDir", QFileInfo(dir).absolutePath());
|
||||
config()->set(Config::LastDir, QFileInfo(dir).absolutePath());
|
||||
}
|
||||
|
||||
m_forgetLastDir = false;
|
||||
|
||||
Reference in New Issue
Block a user