mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:00:05 +00:00
Add default alert action to settings dialog
This commit is contained in:
parent
ff4e3e63cf
commit
061bc8837f
2 changed files with 130 additions and 67 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
#include <scwx/qt/manager/settings_manager.hpp>
|
#include <scwx/qt/manager/settings_manager.hpp>
|
||||||
#include <scwx/qt/map/map_provider.hpp>
|
#include <scwx/qt/map/map_provider.hpp>
|
||||||
#include <scwx/qt/settings/settings_interface.hpp>
|
#include <scwx/qt/settings/settings_interface.hpp>
|
||||||
|
#include <scwx/qt/types/alert_types.hpp>
|
||||||
#include <scwx/qt/ui/radar_site_dialog.hpp>
|
#include <scwx/qt/ui/radar_site_dialog.hpp>
|
||||||
#include <scwx/qt/util/color.hpp>
|
#include <scwx/qt/util/color.hpp>
|
||||||
#include <scwx/qt/util/file.hpp>
|
#include <scwx/qt/util/file.hpp>
|
||||||
|
|
@ -88,6 +89,7 @@ public:
|
||||||
&mapProvider_,
|
&mapProvider_,
|
||||||
&mapboxApiKey_,
|
&mapboxApiKey_,
|
||||||
&mapTilerApiKey_,
|
&mapTilerApiKey_,
|
||||||
|
&defaultAlertAction_,
|
||||||
&updateNotificationsEnabled_,
|
&updateNotificationsEnabled_,
|
||||||
&debugEnabled_}}
|
&debugEnabled_}}
|
||||||
{
|
{
|
||||||
|
|
@ -144,8 +146,9 @@ public:
|
||||||
settings::SettingsInterface<std::string> mapProvider_ {};
|
settings::SettingsInterface<std::string> mapProvider_ {};
|
||||||
settings::SettingsInterface<std::string> mapboxApiKey_ {};
|
settings::SettingsInterface<std::string> mapboxApiKey_ {};
|
||||||
settings::SettingsInterface<std::string> mapTilerApiKey_ {};
|
settings::SettingsInterface<std::string> mapTilerApiKey_ {};
|
||||||
settings::SettingsInterface<bool> updateNotificationsEnabled_ {};
|
settings::SettingsInterface<std::string> defaultAlertAction_ {};
|
||||||
settings::SettingsInterface<bool> debugEnabled_ {};
|
settings::SettingsInterface<bool> updateNotificationsEnabled_ {};
|
||||||
|
settings::SettingsInterface<bool> debugEnabled_ {};
|
||||||
|
|
||||||
std::unordered_map<std::string, settings::SettingsInterface<std::string>>
|
std::unordered_map<std::string, settings::SettingsInterface<std::string>>
|
||||||
colorTables_ {};
|
colorTables_ {};
|
||||||
|
|
@ -331,10 +334,13 @@ void SettingsDialogImpl::SetupGeneralTab()
|
||||||
{
|
{
|
||||||
for (map::MapProvider mapProvider : map::MapProviderIterator())
|
for (map::MapProvider mapProvider : map::MapProviderIterator())
|
||||||
{
|
{
|
||||||
if (boost::iequals(text, map::GetMapProviderName(mapProvider)))
|
const std::string mapProviderName =
|
||||||
|
map::GetMapProviderName(mapProvider);
|
||||||
|
|
||||||
|
if (boost::iequals(text, mapProviderName))
|
||||||
{
|
{
|
||||||
// Return map provider label
|
// Return map provider label
|
||||||
return GetMapProviderName(mapProvider);
|
return mapProviderName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -359,6 +365,42 @@ void SettingsDialogImpl::SetupGeneralTab()
|
||||||
mapTilerApiKey_.SetEditWidget(self_->ui->mapTilerApiKeyLineEdit);
|
mapTilerApiKey_.SetEditWidget(self_->ui->mapTilerApiKeyLineEdit);
|
||||||
mapTilerApiKey_.SetResetButton(self_->ui->resetMapTilerApiKeyButton);
|
mapTilerApiKey_.SetResetButton(self_->ui->resetMapTilerApiKeyButton);
|
||||||
|
|
||||||
|
for (const auto& alertAction : types::AlertActionIterator())
|
||||||
|
{
|
||||||
|
self_->ui->defaultAlertActionComboBox->addItem(
|
||||||
|
QString::fromStdString(types::GetAlertActionName(alertAction)));
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultAlertAction_.SetSettingsVariable(
|
||||||
|
generalSettings.default_alert_action());
|
||||||
|
defaultAlertAction_.SetMapFromValueFunction(
|
||||||
|
[](const std::string& text) -> std::string
|
||||||
|
{
|
||||||
|
for (types::AlertAction alertAction : types::AlertActionIterator())
|
||||||
|
{
|
||||||
|
const std::string alertActionName =
|
||||||
|
types::GetAlertActionName(alertAction);
|
||||||
|
|
||||||
|
if (boost::iequals(text, alertActionName))
|
||||||
|
{
|
||||||
|
// Return alert action label
|
||||||
|
return alertActionName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alert action label not found, return unknown
|
||||||
|
return "?";
|
||||||
|
});
|
||||||
|
defaultAlertAction_.SetMapToValueFunction(
|
||||||
|
[](std::string text) -> std::string
|
||||||
|
{
|
||||||
|
// Convert label to lower case and return
|
||||||
|
boost::to_lower(text);
|
||||||
|
return text;
|
||||||
|
});
|
||||||
|
defaultAlertAction_.SetEditWidget(self_->ui->defaultAlertActionComboBox);
|
||||||
|
defaultAlertAction_.SetResetButton(self_->ui->resetDefaultAlertActionButton);
|
||||||
|
|
||||||
updateNotificationsEnabled_.SetSettingsVariable(
|
updateNotificationsEnabled_.SetSettingsVariable(
|
||||||
generalSettings.update_notifications_enabled());
|
generalSettings.update_notifications_enabled());
|
||||||
updateNotificationsEnabled_.SetEditWidget(
|
updateNotificationsEnabled_.SetEditWidget(
|
||||||
|
|
|
||||||
|
|
@ -109,39 +109,58 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="5" column="2">
|
||||||
|
<widget class="QComboBox" name="mapProviderComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Sizes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QComboBox" name="radarSiteComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Default Radar Site</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" 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>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QLineEdit" name="fontSizesLineEdit"/>
|
<widget class="QLineEdit" name="fontSizesLineEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="6" column="0">
|
||||||
<widget class="QToolButton" name="radarSiteSelectButton">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>Mapbox API Key</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
<item row="7" column="0">
|
||||||
<widget class="QToolButton" name="resetRadarSiteButton">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>MapTiler API Key</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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="4">
|
<item row="2" column="2">
|
||||||
<widget class="QToolButton" name="resetGridWidthButton">
|
<widget class="QSpinBox" name="gridWidthSpinBox"/>
|
||||||
<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>
|
||||||
<item row="6" column="4">
|
<item row="7" column="4">
|
||||||
<widget class="QToolButton" name="resetMapTilerApiKeyButton">
|
<widget class="QToolButton" name="resetMapTilerApiKeyButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
|
|
@ -152,17 +171,10 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="0" column="3">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QToolButton" name="radarSiteSelectButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Font Sizes</string>
|
<string>...</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>MapTiler API Key</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
@ -177,8 +189,22 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="7" column="2">
|
||||||
<widget class="QSpinBox" name="gridWidthSpinBox"/>
|
<widget class="QLineEdit" name="mapTilerApiKeyLineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QSpinBox" name="gridHeightSpinBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QToolButton" name="resetRadarSiteButton">
|
||||||
|
<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>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
|
|
@ -199,12 +225,9 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="2">
|
<item row="6" column="2">
|
||||||
<widget class="QLineEdit" name="mapTilerApiKeyLineEdit"/>
|
<widget class="QLineEdit" name="mapboxApiKeyLineEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="6" column="4">
|
||||||
<widget class="QComboBox" name="radarSiteComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="4">
|
|
||||||
<widget class="QToolButton" name="resetMapboxApiKeyButton">
|
<widget class="QToolButton" name="resetMapboxApiKeyButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
|
|
@ -215,19 +238,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
@ -235,25 +245,36 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="5" 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">
|
<widget class="QLabel" name="label_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Map Provider</string>
|
<string>Map Provider</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="2">
|
<item row="2" column="4">
|
||||||
<widget class="QComboBox" name="mapProviderComboBox"/>
|
<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>
|
||||||
<item row="4" column="4">
|
<item row="8" column="0">
|
||||||
<widget class="QToolButton" name="resetMapProviderButton">
|
<widget class="QLabel" name="defaultAlertActionLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Default Alert Action</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="2">
|
||||||
|
<widget class="QComboBox" name="defaultAlertActionComboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="4">
|
||||||
|
<widget class="QToolButton" name="resetDefaultAlertActionButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue