From d80661211cb5477932d6ad8e38f42df2c0ce2824 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 18 Jun 2022 00:23:21 +0200 Subject: [PATCH] [libcalamares] Introduce convenience for reading Locale map --- src/libcalamares/locale/Global.cpp | 13 +++++++++++++ src/libcalamares/locale/Global.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/libcalamares/locale/Global.cpp b/src/libcalamares/locale/Global.cpp index a23a10478..c9fb27fbc 100644 --- a/src/libcalamares/locale/Global.cpp +++ b/src/libcalamares/locale/Global.cpp @@ -73,6 +73,19 @@ clearGS( Calamares::GlobalStorage& gs ) gs.remove( gsKey ); } +QString +readGS( Calamares::GlobalStorage& gs, const QString& key ) +{ + if ( gs.contains( gsKey ) ) + { + QVariantMap localeConf = gs.value( gsKey ).toMap(); + if ( localeConf.contains( key ) ) + { + return localeConf.value( key ).toString(); + } + } + return QString(); +} } // namespace Locale } // namespace CalamaresUtils diff --git a/src/libcalamares/locale/Global.h b/src/libcalamares/locale/Global.h index abcf43dcd..cf23ef7df 100644 --- a/src/libcalamares/locale/Global.h +++ b/src/libcalamares/locale/Global.h @@ -74,6 +74,12 @@ DLLEXPORT void removeGS( Calamares::GlobalStorage& gs, const QString& key ); */ DLLEXPORT void clearGS( Calamares::GlobalStorage& gs ); +/** @brief Gets a value from the *localeConf* map in @p gs + * + * If the key is not set (or doesn't exist), returns QString(). + */ +DLLEXPORT QString readGS( Calamares::GlobalStorage& gs, const QString& key ); + } // namespace Locale } // namespace CalamaresUtils