Add Map Provider and MapTiler to general settings

This commit is contained in:
Dan Paulat 2023-04-27 22:28:42 -05:00
parent 26067255f0
commit eed7e8e5e9
3 changed files with 35 additions and 1 deletions

View file

@ -1,6 +1,8 @@
#include <scwx/qt/settings/general_settings.hpp>
#include <scwx/qt/settings/settings_container.hpp>
#include <array>
namespace scwx
{
namespace qt
@ -10,6 +12,9 @@ namespace settings
static const std::string logPrefix_ = "scwx::qt::settings::general_settings";
static const std::array<std::string, 2> 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<std::vector<std::int64_t>> fontSizes_ {"font_sizes"};
SettingsVariable<std::int64_t> gridWidth_ {"grid_width"};
SettingsVariable<std::int64_t> gridHeight_ {"grid_height"};
SettingsVariable<std::string> mapProvider_ {"map_provider"};
SettingsVariable<std::string> mapboxApiKey_ {"mapbox_api_key"};
SettingsVariable<std::string> maptilerApiKey_ {"maptiler_api_key"};
SettingsVariable<bool> 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<std::int64_t>& GeneralSettings::grid_width() const
return p->gridWidth_;
}
SettingsVariable<std::string>& GeneralSettings::map_provider() const
{
return p->mapProvider_;
}
SettingsVariable<std::string>& GeneralSettings::mapbox_api_key() const
{
return p->mapboxApiKey_;
}
SettingsVariable<std::string>& GeneralSettings::maptiler_api_key() const
{
return p->maptilerApiKey_;
}
SettingsVariable<bool>& 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_);
}

View file

@ -32,7 +32,9 @@ public:
SettingsContainer<std::vector<std::int64_t>>& font_sizes() const;
SettingsVariable<std::int64_t>& grid_height() const;
SettingsVariable<std::int64_t>& grid_width() const;
SettingsVariable<std::string>& map_provider() const;
SettingsVariable<std::string>& mapbox_api_key() const;
SettingsVariable<std::string>& maptiler_api_key() const;
SettingsVariable<bool>& update_notifications_enabled() const;
friend bool operator==(const GeneralSettings& lhs,

@ -1 +1 @@
Subproject commit 5b5073780fe44e55eb4c33799036683b28ffd2bd
Subproject commit 938b0240e51aff37530adc679a11d0e65e5e96ce