diff options
Diffstat (limited to 'src/settings.cpp')
-rw-r--r-- | src/settings.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 25cc6c0..f030dfd 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -19,6 +19,7 @@ ******************************************************************************/ #include "settings.h" +#include <QStandardPaths> QString Settings::_path = QString(""); @@ -41,13 +42,20 @@ QString Settings::staticFilePath() QVariant Settings::value(const QString &key, const QVariant &defaultValue) const { + // get the actual value QString value = QSettings::value(key, defaultValue).toString(); + // check if there is a reference 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()); } + // check if key is a path, in which case replace '~' with the home location + if(key.endsWith(QLatin1String("path"), Qt::CaseInsensitive)) { + value.replace('~', QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); + } + return QVariant(value); } |