From eed7e8e5e9aa8f28c227e0bd5d0e3e00138a87c5 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Thu, 27 Apr 2023 22:28:42 -0500 Subject: [PATCH] Add Map Provider and MapTiler to general settings --- .../scwx/qt/settings/general_settings.cpp | 32 +++++++++++++++++++ .../scwx/qt/settings/general_settings.hpp | 2 ++ test/data | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/scwx-qt/source/scwx/qt/settings/general_settings.cpp b/scwx-qt/source/scwx/qt/settings/general_settings.cpp index 55f74a00..e1537554 100644 --- a/scwx-qt/source/scwx/qt/settings/general_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/general_settings.cpp @@ -1,6 +1,8 @@ #include #include +#include + namespace scwx { namespace qt @@ -10,6 +12,9 @@ namespace settings static const std::string logPrefix_ = "scwx::qt::settings::general_settings"; +static const std::array kMapProviderValues_ {"mapbox", + "maptiler"}; + class GeneralSettingsImpl { public: @@ -20,7 +25,9 @@ public: fontSizes_.SetDefault({16}); gridWidth_.SetDefault(1); gridHeight_.SetDefault(1); + mapProvider_.SetDefault("maptiler"); mapboxApiKey_.SetDefault("?"); + maptilerApiKey_.SetDefault("?"); updateNotificationsEnabled_.SetDefault(true); fontSizes_.SetElementMinimum(1); @@ -31,8 +38,17 @@ public: gridWidth_.SetMaximum(2); gridHeight_.SetMinimum(1); gridHeight_.SetMaximum(2); + mapProvider_.SetValidator( + [](const std::string& value) + { + return std::find(kMapProviderValues_.cbegin(), + kMapProviderValues_.cend(), + value) != kMapProviderValues_.cend(); + }); mapboxApiKey_.SetValidator([](const std::string& value) { return !value.empty(); }); + maptilerApiKey_.SetValidator([](const std::string& value) + { return !value.empty(); }); } ~GeneralSettingsImpl() {} @@ -42,7 +58,9 @@ public: SettingsContainer> fontSizes_ {"font_sizes"}; SettingsVariable gridWidth_ {"grid_width"}; SettingsVariable gridHeight_ {"grid_height"}; + SettingsVariable mapProvider_ {"map_provider"}; SettingsVariable mapboxApiKey_ {"mapbox_api_key"}; + SettingsVariable maptilerApiKey_ {"maptiler_api_key"}; SettingsVariable updateNotificationsEnabled_ {"update_notifications"}; }; @@ -54,7 +72,9 @@ GeneralSettings::GeneralSettings() : &p->fontSizes_, &p->gridWidth_, &p->gridHeight_, + &p->mapProvider_, &p->mapboxApiKey_, + &p->maptilerApiKey_, &p->updateNotificationsEnabled_}); SetDefaults(); } @@ -90,11 +110,21 @@ SettingsVariable& GeneralSettings::grid_width() const return p->gridWidth_; } +SettingsVariable& GeneralSettings::map_provider() const +{ + return p->mapProvider_; +} + SettingsVariable& GeneralSettings::mapbox_api_key() const { return p->mapboxApiKey_; } +SettingsVariable& GeneralSettings::maptiler_api_key() const +{ + return p->maptilerApiKey_; +} + SettingsVariable& GeneralSettings::update_notifications_enabled() const { return p->updateNotificationsEnabled_; @@ -107,7 +137,9 @@ bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs) lhs.p->fontSizes_ == rhs.p->fontSizes_ && lhs.p->gridWidth_ == rhs.p->gridWidth_ && lhs.p->gridHeight_ == rhs.p->gridHeight_ && + lhs.p->mapProvider_ == rhs.p->mapProvider_ && lhs.p->mapboxApiKey_ == rhs.p->mapboxApiKey_ && + lhs.p->maptilerApiKey_ == rhs.p->maptilerApiKey_ && lhs.p->updateNotificationsEnabled_ == rhs.p->updateNotificationsEnabled_); } diff --git a/scwx-qt/source/scwx/qt/settings/general_settings.hpp b/scwx-qt/source/scwx/qt/settings/general_settings.hpp index 48757e28..a565f09e 100644 --- a/scwx-qt/source/scwx/qt/settings/general_settings.hpp +++ b/scwx-qt/source/scwx/qt/settings/general_settings.hpp @@ -32,7 +32,9 @@ public: SettingsContainer>& font_sizes() const; SettingsVariable& grid_height() const; SettingsVariable& grid_width() const; + SettingsVariable& map_provider() const; SettingsVariable& mapbox_api_key() const; + SettingsVariable& maptiler_api_key() const; SettingsVariable& update_notifications_enabled() const; friend bool operator==(const GeneralSettings& lhs, diff --git a/test/data b/test/data index 5b507378..938b0240 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 5b5073780fe44e55eb4c33799036683b28ffd2bd +Subproject commit 938b0240e51aff37530adc679a11d0e65e5e96ce