mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 22:50:05 +00:00
Add Map Provider and MapTiler API key to settings dialog
This commit is contained in:
parent
eed7e8e5e9
commit
9c5de8e9ee
2 changed files with 136 additions and 49 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <scwx/util/logger.hpp>
|
||||
#include <scwx/util/threads.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <fmt/format.h>
|
||||
#include <QColorDialog>
|
||||
#include <QFileDialog>
|
||||
|
|
@ -35,6 +36,8 @@ struct ColorTableConversions
|
|||
float scale {1.0f};
|
||||
};
|
||||
|
||||
static const std::array<std::string, 2> kMapProviders_ {"Mapbox", "MapTiler"};
|
||||
|
||||
static const std::array<std::pair<std::string, std::string>, 15>
|
||||
kColorTableTypes_ {std::pair {"BR", "BR"},
|
||||
std::pair {"BV", "BV"},
|
||||
|
|
@ -83,7 +86,9 @@ public:
|
|||
&fontSizes_,
|
||||
&gridWidth_,
|
||||
&gridHeight_,
|
||||
&mapProvider_,
|
||||
&mapboxApiKey_,
|
||||
&mapTilerApiKey_,
|
||||
&updateNotificationsEnabled_,
|
||||
&debugEnabled_}}
|
||||
{
|
||||
|
|
@ -137,7 +142,9 @@ public:
|
|||
settings::SettingsInterface<std::vector<std::int64_t>> fontSizes_ {};
|
||||
settings::SettingsInterface<std::int64_t> gridWidth_ {};
|
||||
settings::SettingsInterface<std::int64_t> gridHeight_ {};
|
||||
settings::SettingsInterface<std::string> mapProvider_ {};
|
||||
settings::SettingsInterface<std::string> mapboxApiKey_ {};
|
||||
settings::SettingsInterface<std::string> mapTilerApiKey_ {};
|
||||
settings::SettingsInterface<bool> updateNotificationsEnabled_ {};
|
||||
settings::SettingsInterface<bool> debugEnabled_ {};
|
||||
|
||||
|
|
@ -313,10 +320,48 @@ void SettingsDialogImpl::SetupGeneralTab()
|
|||
gridHeight_.SetEditWidget(self_->ui->gridHeightSpinBox);
|
||||
gridHeight_.SetResetButton(self_->ui->resetGridHeightButton);
|
||||
|
||||
for (const auto& mapProvider : kMapProviders_)
|
||||
{
|
||||
self_->ui->mapProviderComboBox->addItem(
|
||||
QString::fromStdString(mapProvider));
|
||||
}
|
||||
|
||||
mapProvider_.SetSettingsVariable(generalSettings.map_provider());
|
||||
mapProvider_.SetMapFromValueFunction(
|
||||
[](const std::string& text) -> std::string
|
||||
{
|
||||
auto it = std::find_if(kMapProviders_.cbegin(),
|
||||
kMapProviders_.cend(),
|
||||
[&text](const std::string& mapProvider)
|
||||
{ return boost::iequals(text, mapProvider); });
|
||||
|
||||
if (it == kMapProviders_.cend())
|
||||
{
|
||||
// Map provider label not found, return unknown
|
||||
return "?";
|
||||
}
|
||||
|
||||
// Return map provider label
|
||||
return *it;
|
||||
});
|
||||
mapProvider_.SetMapToValueFunction(
|
||||
[](std::string text) -> std::string
|
||||
{
|
||||
// Convert label to lower case and return
|
||||
boost::to_lower(text);
|
||||
return text;
|
||||
});
|
||||
mapProvider_.SetEditWidget(self_->ui->mapProviderComboBox);
|
||||
mapProvider_.SetResetButton(self_->ui->resetMapProviderButton);
|
||||
|
||||
mapboxApiKey_.SetSettingsVariable(generalSettings.mapbox_api_key());
|
||||
mapboxApiKey_.SetEditWidget(self_->ui->mapboxApiKeyLineEdit);
|
||||
mapboxApiKey_.SetResetButton(self_->ui->resetMapboxApiKeyButton);
|
||||
|
||||
mapTilerApiKey_.SetSettingsVariable(generalSettings.maptiler_api_key());
|
||||
mapTilerApiKey_.SetEditWidget(self_->ui->mapTilerApiKeyLineEdit);
|
||||
mapTilerApiKey_.SetResetButton(self_->ui->resetMapTilerApiKeyButton);
|
||||
|
||||
updateNotificationsEnabled_.SetSettingsVariable(
|
||||
generalSettings.update_notifications_enabled());
|
||||
updateNotificationsEnabled_.SetEditWidget(
|
||||
|
|
|
|||
|
|
@ -109,43 +109,14 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Default Radar Site</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="fontSizesLineEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Grid Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QSpinBox" name="gridHeightSpinBox"/>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QToolButton" name="resetGridWidthButton">
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="radarSiteSelectButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="QToolButton" name="resetMapboxApiKeyButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
|
|
@ -159,11 +130,41 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSpinBox" name="gridWidthSpinBox"/>
|
||||
<item row="2" column="4">
|
||||
<widget class="QToolButton" name="resetGridWidthButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="radarSiteComboBox"/>
|
||||
<item row="6" column="4">
|
||||
<widget class="QToolButton" name="resetMapTilerApiKeyButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Font Sizes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>MapTiler API Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QToolButton" name="resetGridHeightButton">
|
||||
|
|
@ -176,13 +177,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="fontSizesLineEdit"/>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSpinBox" name="gridWidthSpinBox"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Mapbox API Key</string>
|
||||
<string>Grid Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -197,16 +198,36 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLineEdit" name="mapboxApiKeyLineEdit"/>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLineEdit" name="mapTilerApiKeyLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="radarSiteComboBox"/>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="QToolButton" name="resetMapboxApiKeyButton">
|
||||
<property name="text">
|
||||
<string>Font Sizes</string>
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLineEdit" name="mapboxApiKeyLineEdit"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Mapbox API Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QSpinBox" name="gridHeightSpinBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
|
|
@ -214,11 +235,32 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="radarSiteSelectButton">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Default Radar Site</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Map Provider</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QComboBox" name="mapProviderComboBox"/>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="QToolButton" name="resetMapProviderButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue