aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/utils/CacheUtils.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-15 09:22:32 +0000
committersaturneric <[email protected]>2024-01-15 09:22:32 +0000
commit6c632d70b391f8b317c68f7db8cfd217f9370995 (patch)
tree4136eb7164d9f910527c0392d12bd4854a2fdcff /src/core/utils/CacheUtils.cpp
parentrefactor: remove boost and use QString instead of std::filesystem::path (diff)
downloadGpgFrontend-6c632d70b391f8b317c68f7db8cfd217f9370995.tar.gz
GpgFrontend-6c632d70b391f8b317c68f7db8cfd217f9370995.zip
feat: use qt json support components in data object and infos gathering module
Diffstat (limited to 'src/core/utils/CacheUtils.cpp')
-rw-r--r--src/core/utils/CacheUtils.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/core/utils/CacheUtils.cpp b/src/core/utils/CacheUtils.cpp
index 575634ae..5e8657fa 100644
--- a/src/core/utils/CacheUtils.cpp
+++ b/src/core/utils/CacheUtils.cpp
@@ -33,14 +33,17 @@
namespace GpgFrontend {
void SetTempCacheValue(const QString& key, const QString& value) {
- nlohmann::json cache_json = value.toStdString();
- CacheManager::GetInstance().SaveCache(key, cache_json);
+ QJsonDocument json;
+ json.setObject(QJsonObject({{key, value}}));
+ CacheManager::GetInstance().SaveCache(key, json);
}
auto GetTempCacheValue(const QString& key) -> QString {
- nlohmann::json cache_json = "";
- cache_json = CacheManager::GetInstance().LoadCache(key, cache_json);
- return QString::fromStdString(cache_json.template get<std::string>());
+ QJsonDocument json = CacheManager::GetInstance().LoadCache(key);
+ if (!json.isObject()) return {};
+ auto json_object = json.object();
+ if (!json_object.contains(key) && json_object[key].isString()) return {};
+ return json_object[key].toString();
}
void ResetTempCacheValue(const QString& key) {