diff options
Diffstat (limited to 'src/settings.cpp')
-rw-r--r-- | src/settings.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index e4871ad..0d69e23 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -25,15 +25,24 @@ QString Settings::_path = QString(""); Settings::Settings(QObject *parent) : QSettings(_path, QSettings::IniFormat, parent) { + setIniCodec("UTF-8"); } -Settings::~Settings() +void Settings::setFilePath(const QString &path) { - this->sync(); + qDebug("config=[%s]", qUtf8Printable(path)); + _path = path; } -void Settings::setFilepath(const QString &path) +QVariant Settings::value(const QString &key, const QVariant &defaultValue) const { - qDebug("Setting config file location to: %s", qUtf8Printable(path)); - _path = path; + QString value = QSettings::value(key, defaultValue).toString(); + + QRegularExpressionMatch referenceMatch = referencePattern.match(value); + if(referenceMatch.hasMatch()) { + QString pattern = referenceMatch.capturedTexts().first(); + value.replace(pattern, this->value(pattern.mid(1, pattern.length()-2)).toString()); + } + + return QVariant(value); } |