|
|
|
@ -1,5 +1,6 @@
@@ -1,5 +1,6 @@
|
|
|
|
|
/*
|
|
|
|
|
* Bittorrent Client using Qt and libtorrent. |
|
|
|
|
* Copyright (C) 2023 Mike Tzou (Chocobo1) |
|
|
|
|
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru> |
|
|
|
|
* Copyright (C) 2014 sledgehammer999 <hammered999@gmail.com> |
|
|
|
|
* |
|
|
|
@ -41,10 +42,7 @@
@@ -41,10 +42,7 @@
|
|
|
|
|
#include "utils/string.h" |
|
|
|
|
|
|
|
|
|
template <typename T> |
|
|
|
|
struct IsQFlags : std::false_type {}; |
|
|
|
|
|
|
|
|
|
template <typename T> |
|
|
|
|
struct IsQFlags<QFlags<T>> : std::true_type {}; |
|
|
|
|
concept IsQFlags = std::same_as<T, QFlags<typename T::enum_type>>; |
|
|
|
|
|
|
|
|
|
// There are 2 ways for class `T` provide serialization support into `SettingsStorage`:
|
|
|
|
|
// 1. If the `T` state is intended for users to edit (via a text editor), then
|
|
|
|
@ -76,7 +74,7 @@ public:
@@ -76,7 +74,7 @@ public:
|
|
|
|
|
const auto value = loadValue<QString>(key); |
|
|
|
|
return Utils::String::toEnum(value, defaultValue); |
|
|
|
|
} |
|
|
|
|
else if constexpr (IsQFlags<T>::value) |
|
|
|
|
else if constexpr (IsQFlags<T>) |
|
|
|
|
{ |
|
|
|
|
const typename T::Int value = loadValue(key, static_cast<typename T::Int>(defaultValue)); |
|
|
|
|
return T {value}; |
|
|
|
@ -101,7 +99,7 @@ public:
@@ -101,7 +99,7 @@ public:
|
|
|
|
|
storeValueImpl(key, value.toString()); |
|
|
|
|
else if constexpr (std::is_enum_v<T>) |
|
|
|
|
storeValueImpl(key, Utils::String::fromEnum(value)); |
|
|
|
|
else if constexpr (IsQFlags<T>::value) |
|
|
|
|
else if constexpr (IsQFlags<T>) |
|
|
|
|
storeValueImpl(key, static_cast<typename T::Int>(value)); |
|
|
|
|
else |
|
|
|
|
storeValueImpl(key, QVariant::fromValue(value)); |
|
|
|
|