aboutsummaryrefslogtreecommitdiff
path: root/lib/configuration
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-12-30 21:16:41 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-12-30 21:16:41 +0100
commitdcf4777c0dc2a435d7747a500e29d5a1077abecd (patch)
tree5413b79c4157e055440ed7ffdc56ad10553acf6c /lib/configuration
parentFix filter.header not working (diff)
downloadsmolbote-dcf4777c0dc2a435d7747a500e29d5a1077abecd.tar.xz
Configuration: fix homepath patching for value<QString>
Diffstat (limited to 'lib/configuration')
-rw-r--r--lib/configuration/configuration.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/configuration/configuration.h b/lib/configuration/configuration.h
index 2bdd2c5..b05728a 100644
--- a/lib/configuration/configuration.h
+++ b/lib/configuration/configuration.h
@@ -46,24 +46,24 @@ public:
// path is guaranteed to exist, so using vm[path] is safe
- if constexpr(std::is_same_v<T, QString>) {
- return std::optional<QString>(QString::fromStdString(vm[path].as<std::string>()));
-
- } else if constexpr(std::is_same_v<T, QStringList>) {
+ if constexpr(std::is_same_v<T, QStringList>) {
QStringList r;
for(const std::string &item : vm[path].as<std::vector<std::string>>()) {
r.append(QString::fromStdString(item));
}
return std::optional<QStringList>(r);
- } else if constexpr(std::is_same_v<T, std::string>) {
+ } else if constexpr(std::is_same_v<T, std::string> || std::is_same_v<T, QString>) {
if(vm[path].value().type() == typeid(int)) {
- return std::optional<std::string>(std::to_string(vm[path].as<int>()));
+ if constexpr(std::is_same_v<T, std::string>)
+ return std::optional<std::string>(std::to_string(vm[path].as<int>()));
+ else if constexpr(std::is_same_v<T, QString>)
+ return std::optional<QString>(QString::number(vm[path].as<int>()));
}
if(vm[path].value().type() == typeid(bool)) {
- return std::optional<std::string>(vm[path].as<bool>() ? "true" : "false");
+ return std::optional<T>(vm[path].as<bool>() ? "true" : "false");
}
std::string r = vm[path].as<std::string>();
@@ -73,7 +73,10 @@ public:
r.replace(0, 1, m_homePath);
}
- return std::optional<std::string>(r);
+ if constexpr(std::is_same_v<T, std::string>)
+ return std::optional<std::string>(r);
+ else if constexpr(std::is_same_v<T, QString>)
+ return std::optional<QString>(QString::fromStdString(r));
} else
return std::optional<T>(vm[path].as<T>());