aboutsummaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-02-23 17:19:32 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-02-23 17:19:32 +0100
commitabd011f7cf8d298b8bbbe30eedb329094d43c0b9 (patch)
tree300909ce22e5c356a4735dbedaf795a594055c9e /src/settings.cpp
parentMinor features (diff)
downloadsmolbote-abd011f7cf8d298b8bbbe30eedb329094d43c0b9.tar.xz
Download manager improvements
Added shortcut for download dialog Dialog has proper title Settings replaces ~ with home location Showing download item details
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp8
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);
}