aboutsummaryrefslogtreecommitdiff
path: root/lib/configuration
diff options
context:
space:
mode:
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>());