mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13:10:04 +00:00 
			
		
		
		
	Add clock format and default time zone to settings dialog
This commit is contained in:
		
							parent
							
								
									2a0ab9ad93
								
							
						
					
					
						commit
						bb287dad9c
					
				
					 2 changed files with 178 additions and 103 deletions
				
			
		|  | @ -19,6 +19,7 @@ | ||||||
| #include <scwx/qt/types/location_types.hpp> | #include <scwx/qt/types/location_types.hpp> | ||||||
| #include <scwx/qt/types/qt_types.hpp> | #include <scwx/qt/types/qt_types.hpp> | ||||||
| #include <scwx/qt/types/text_types.hpp> | #include <scwx/qt/types/text_types.hpp> | ||||||
|  | #include <scwx/qt/types/time_types.hpp> | ||||||
| #include <scwx/qt/ui/county_dialog.hpp> | #include <scwx/qt/ui/county_dialog.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> | ||||||
|  | @ -129,6 +130,8 @@ public: | ||||||
|           &mapTilerApiKey_, |           &mapTilerApiKey_, | ||||||
|           &theme_, |           &theme_, | ||||||
|           &defaultAlertAction_, |           &defaultAlertAction_, | ||||||
|  |           &clockFormat_, | ||||||
|  |           &defaultTimeZone_, | ||||||
|           &antiAliasingEnabled_, |           &antiAliasingEnabled_, | ||||||
|           &showMapAttribution_, |           &showMapAttribution_, | ||||||
|           &showMapLogo_, |           &showMapLogo_, | ||||||
|  | @ -220,6 +223,8 @@ public: | ||||||
|    settings::SettingsInterface<std::string>  mapboxApiKey_ {}; |    settings::SettingsInterface<std::string>  mapboxApiKey_ {}; | ||||||
|    settings::SettingsInterface<std::string>  mapTilerApiKey_ {}; |    settings::SettingsInterface<std::string>  mapTilerApiKey_ {}; | ||||||
|    settings::SettingsInterface<std::string>  defaultAlertAction_ {}; |    settings::SettingsInterface<std::string>  defaultAlertAction_ {}; | ||||||
|  |    settings::SettingsInterface<std::string>  clockFormat_ {}; | ||||||
|  |    settings::SettingsInterface<std::string>  defaultTimeZone_ {}; | ||||||
|    settings::SettingsInterface<std::string>  theme_ {}; |    settings::SettingsInterface<std::string>  theme_ {}; | ||||||
|    settings::SettingsInterface<bool>         antiAliasingEnabled_ {}; |    settings::SettingsInterface<bool>         antiAliasingEnabled_ {}; | ||||||
|    settings::SettingsInterface<bool>         showMapAttribution_ {}; |    settings::SettingsInterface<bool>         showMapAttribution_ {}; | ||||||
|  | @ -590,23 +595,9 @@ void SettingsDialogImpl::SetupGeneralTab() | ||||||
|    defaultAlertAction_.SetSettingsVariable( |    defaultAlertAction_.SetSettingsVariable( | ||||||
|       generalSettings.default_alert_action()); |       generalSettings.default_alert_action()); | ||||||
|    defaultAlertAction_.SetMapFromValueFunction( |    defaultAlertAction_.SetMapFromValueFunction( | ||||||
|       [](const std::string& text) -> std::string |       SCWX_ENUM_MAP_FROM_VALUE(types::AlertAction, | ||||||
|       { |                                types::AlertActionIterator(), | ||||||
|          for (types::AlertAction alertAction : types::AlertActionIterator()) |                                types::GetAlertActionName)); | ||||||
|          { |  | ||||||
|             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( |    defaultAlertAction_.SetMapToValueFunction( | ||||||
|       [](std::string text) -> std::string |       [](std::string text) -> std::string | ||||||
|       { |       { | ||||||
|  | @ -617,6 +608,48 @@ void SettingsDialogImpl::SetupGeneralTab() | ||||||
|    defaultAlertAction_.SetEditWidget(self_->ui->defaultAlertActionComboBox); |    defaultAlertAction_.SetEditWidget(self_->ui->defaultAlertActionComboBox); | ||||||
|    defaultAlertAction_.SetResetButton(self_->ui->resetDefaultAlertActionButton); |    defaultAlertAction_.SetResetButton(self_->ui->resetDefaultAlertActionButton); | ||||||
| 
 | 
 | ||||||
|  |    for (const auto& clockFormat : types::ClockFormatIterator()) | ||||||
|  |    { | ||||||
|  |       self_->ui->clockFormatComboBox->addItem( | ||||||
|  |          QString::fromStdString(types::GetClockFormatName(clockFormat))); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    clockFormat_.SetSettingsVariable(generalSettings.clock_format()); | ||||||
|  |    clockFormat_.SetMapFromValueFunction( | ||||||
|  |       SCWX_ENUM_MAP_FROM_VALUE(types::ClockFormat, | ||||||
|  |                                types::ClockFormatIterator(), | ||||||
|  |                                types::GetClockFormatName)); | ||||||
|  |    clockFormat_.SetMapToValueFunction( | ||||||
|  |       [](std::string text) -> std::string | ||||||
|  |       { | ||||||
|  |          // Convert label to lower case and return
 | ||||||
|  |          boost::to_lower(text); | ||||||
|  |          return text; | ||||||
|  |       }); | ||||||
|  |    clockFormat_.SetEditWidget(self_->ui->clockFormatComboBox); | ||||||
|  |    clockFormat_.SetResetButton(self_->ui->resetClockFormatButton); | ||||||
|  | 
 | ||||||
|  |    for (const auto& timeZone : types::DefaultTimeZoneIterator()) | ||||||
|  |    { | ||||||
|  |       self_->ui->defaultTimeZoneComboBox->addItem( | ||||||
|  |          QString::fromStdString(types::GetDefaultTimeZoneName(timeZone))); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    defaultTimeZone_.SetSettingsVariable(generalSettings.default_time_zone()); | ||||||
|  |    defaultTimeZone_.SetMapFromValueFunction( | ||||||
|  |       SCWX_ENUM_MAP_FROM_VALUE(types::DefaultTimeZone, | ||||||
|  |                                types::DefaultTimeZoneIterator(), | ||||||
|  |                                types::GetDefaultTimeZoneName)); | ||||||
|  |    defaultTimeZone_.SetMapToValueFunction( | ||||||
|  |       [](std::string text) -> std::string | ||||||
|  |       { | ||||||
|  |          // Convert label to lower case and return
 | ||||||
|  |          boost::to_lower(text); | ||||||
|  |          return text; | ||||||
|  |       }); | ||||||
|  |    defaultTimeZone_.SetEditWidget(self_->ui->defaultTimeZoneComboBox); | ||||||
|  |    defaultTimeZone_.SetResetButton(self_->ui->resetDefaultTimeZoneButton); | ||||||
|  | 
 | ||||||
|    antiAliasingEnabled_.SetSettingsVariable( |    antiAliasingEnabled_.SetSettingsVariable( | ||||||
|       generalSettings.anti_aliasing_enabled()); |       generalSettings.anti_aliasing_enabled()); | ||||||
|    antiAliasingEnabled_.SetEditWidget(self_->ui->antiAliasingEnabledCheckBox); |    antiAliasingEnabled_.SetEditWidget(self_->ui->antiAliasingEnabledCheckBox); | ||||||
|  |  | ||||||
|  | @ -129,8 +129,18 @@ | ||||||
|               <property name="bottomMargin"> |               <property name="bottomMargin"> | ||||||
|                <number>0</number> |                <number>0</number> | ||||||
|               </property> |               </property> | ||||||
|               <item row="5" 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="0" column="2"> | ||||||
|  |                <widget class="QComboBox" name="themeComboBox"/> | ||||||
|  |               </item> | ||||||
|  |               <item row="0" column="4"> | ||||||
|  |                <widget class="QToolButton" name="resetThemeButton"> | ||||||
|                 <property name="text"> |                 <property name="text"> | ||||||
|                  <string>...</string> |                  <string>...</string> | ||||||
|                 </property> |                 </property> | ||||||
|  | @ -140,46 +150,8 @@ | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|               <item row="1" column="3"> |               <item row="8" column="2"> | ||||||
|                <widget class="QToolButton" name="radarSiteSelectButton"> |                <widget class="QComboBox" name="defaultAlertActionComboBox"/> | ||||||
|                 <property name="text"> |  | ||||||
|                  <string>...</string> |  | ||||||
|                 </property> |  | ||||||
|                </widget> |  | ||||||
|               </item> |  | ||||||
|               <item row="5" column="0"> |  | ||||||
|                <widget class="QLabel" name="label_7"> |  | ||||||
|                 <property name="text"> |  | ||||||
|                  <string>Map Provider</string> |  | ||||||
|                 </property> |  | ||||||
|                </widget> |  | ||||||
|               </item> |  | ||||||
|               <item row="1" column="2"> |  | ||||||
|                <widget class="QComboBox" name="radarSiteComboBox"/> |  | ||||||
|               </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="2"> |  | ||||||
|                <widget class="QSpinBox" name="gridWidthSpinBox"/> |  | ||||||
|               </item> |  | ||||||
|               <item row="1" 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="6" column="2"> |               <item row="6" column="2"> | ||||||
|                <widget class="QLineEdit" name="mapboxApiKeyLineEdit"> |                <widget class="QLineEdit" name="mapboxApiKeyLineEdit"> | ||||||
|  | @ -188,6 +160,13 @@ | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|  |               <item row="10" column="0"> | ||||||
|  |                <widget class="QLabel" name="label_21"> | ||||||
|  |                 <property name="text"> | ||||||
|  |                  <string>Default Time Zone</string> | ||||||
|  |                 </property> | ||||||
|  |                </widget> | ||||||
|  |               </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"> | ||||||
|  | @ -195,10 +174,17 @@ | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|               <item row="8" column="0"> |               <item row="0" column="0"> | ||||||
|                <widget class="QLabel" name="defaultAlertActionLabel"> |                <widget class="QLabel" name="label_5"> | ||||||
|                 <property name="text"> |                 <property name="text"> | ||||||
|                  <string>Default Alert Action</string> |                  <string>Theme</string> | ||||||
|  |                 </property> | ||||||
|  |                </widget> | ||||||
|  |               </item> | ||||||
|  |               <item row="5" column="0"> | ||||||
|  |                <widget class="QLabel" name="label_7"> | ||||||
|  |                 <property name="text"> | ||||||
|  |                  <string>Map Provider</string> | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|  | @ -209,34 +195,6 @@ | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|               <item row="1" column="0"> |  | ||||||
|                <widget class="QLabel" name="label"> |  | ||||||
|                 <property name="text"> |  | ||||||
|                  <string>Default Radar Site</string> |  | ||||||
|                 </property> |  | ||||||
|                </widget> |  | ||||||
|               </item> |  | ||||||
|               <item row="7" column="2"> |  | ||||||
|                <widget class="QLineEdit" name="mapTilerApiKeyLineEdit"> |  | ||||||
|                 <property name="echoMode"> |  | ||||||
|                  <enum>QLineEdit::Password</enum> |  | ||||||
|                 </property> |  | ||||||
|                </widget> |  | ||||||
|               </item> |  | ||||||
|               <item row="8" column="2"> |  | ||||||
|                <widget class="QComboBox" name="defaultAlertActionComboBox"/> |  | ||||||
|               </item> |  | ||||||
|               <item row="7" 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="3" column="4"> |               <item row="3" column="4"> | ||||||
|                <widget class="QToolButton" name="resetGridHeightButton"> |                <widget class="QToolButton" name="resetGridHeightButton"> | ||||||
|                 <property name="text"> |                 <property name="text"> | ||||||
|  | @ -251,10 +209,25 @@ | ||||||
|               <item row="5" column="2"> |               <item row="5" column="2"> | ||||||
|                <widget class="QComboBox" name="mapProviderComboBox"/> |                <widget class="QComboBox" name="mapProviderComboBox"/> | ||||||
|               </item> |               </item> | ||||||
|               <item row="6" column="0"> |               <item row="7" column="4"> | ||||||
|                <widget class="QLabel" name="label_4"> |                <widget class="QToolButton" name="resetMapTilerApiKeyButton"> | ||||||
|                 <property name="text"> |                 <property name="text"> | ||||||
|                  <string>Mapbox API Key</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="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> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|  | @ -269,8 +242,21 @@ | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|               <item row="8" column="4"> |               <item row="9" column="0"> | ||||||
|                <widget class="QToolButton" name="resetDefaultAlertActionButton"> |                <widget class="QLabel" name="label_20"> | ||||||
|  |                 <property name="text"> | ||||||
|  |                  <string>Clock Format</string> | ||||||
|  |                 </property> | ||||||
|  |                </widget> | ||||||
|  |               </item> | ||||||
|  |               <item row="2" column="2"> | ||||||
|  |                <widget class="QSpinBox" name="gridWidthSpinBox"/> | ||||||
|  |               </item> | ||||||
|  |               <item row="9" column="2"> | ||||||
|  |                <widget class="QComboBox" name="clockFormatComboBox"/> | ||||||
|  |               </item> | ||||||
|  |               <item row="1" column="4"> | ||||||
|  |                <widget class="QToolButton" name="resetRadarSiteButton"> | ||||||
|                 <property name="text"> |                 <property name="text"> | ||||||
|                  <string>...</string> |                  <string>...</string> | ||||||
|                 </property> |                 </property> | ||||||
|  | @ -280,6 +266,23 @@ | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|  |               <item row="1" column="2"> | ||||||
|  |                <widget class="QComboBox" name="radarSiteComboBox"/> | ||||||
|  |               </item> | ||||||
|  |               <item row="1" column="0"> | ||||||
|  |                <widget class="QLabel" name="label"> | ||||||
|  |                 <property name="text"> | ||||||
|  |                  <string>Default Radar Site</string> | ||||||
|  |                 </property> | ||||||
|  |                </widget> | ||||||
|  |               </item> | ||||||
|  |               <item row="6" column="0"> | ||||||
|  |                <widget class="QLabel" name="label_4"> | ||||||
|  |                 <property name="text"> | ||||||
|  |                  <string>Mapbox API Key</string> | ||||||
|  |                 </property> | ||||||
|  |                </widget> | ||||||
|  |               </item> | ||||||
|               <item row="6" column="4"> |               <item row="6" column="4"> | ||||||
|                <widget class="QToolButton" name="resetMapboxApiKeyButton"> |                <widget class="QToolButton" name="resetMapboxApiKeyButton"> | ||||||
|                 <property name="text"> |                 <property name="text"> | ||||||
|  | @ -291,18 +294,57 @@ | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|               <item row="0" column="0"> |               <item row="3" column="0"> | ||||||
|                <widget class="QLabel" name="label_5"> |                <widget class="QLabel" name="label_3"> | ||||||
|                 <property name="text"> |                 <property name="text"> | ||||||
|                  <string>Theme</string> |                  <string>Grid Height</string> | ||||||
|                 </property> |                 </property> | ||||||
|                </widget> |                </widget> | ||||||
|               </item> |               </item> | ||||||
|               <item row="0" column="2"> |               <item row="8" column="4"> | ||||||
|                <widget class="QComboBox" name="themeComboBox"/> |                <widget class="QToolButton" name="resetDefaultAlertActionButton"> | ||||||
|  |                 <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="0" column="4"> |               <item row="1" column="3"> | ||||||
|                <widget class="QToolButton" name="resetThemeButton"> |                <widget class="QToolButton" name="radarSiteSelectButton"> | ||||||
|  |                 <property name="text"> | ||||||
|  |                  <string>...</string> | ||||||
|  |                 </property> | ||||||
|  |                </widget> | ||||||
|  |               </item> | ||||||
|  |               <item row="7" column="2"> | ||||||
|  |                <widget class="QLineEdit" name="mapTilerApiKeyLineEdit"> | ||||||
|  |                 <property name="echoMode"> | ||||||
|  |                  <enum>QLineEdit::Password</enum> | ||||||
|  |                 </property> | ||||||
|  |                </widget> | ||||||
|  |               </item> | ||||||
|  |               <item row="3" column="2"> | ||||||
|  |                <widget class="QSpinBox" name="gridHeightSpinBox"/> | ||||||
|  |               </item> | ||||||
|  |               <item row="10" column="2"> | ||||||
|  |                <widget class="QComboBox" name="defaultTimeZoneComboBox"/> | ||||||
|  |               </item> | ||||||
|  |               <item row="9" column="4"> | ||||||
|  |                <widget class="QToolButton" name="resetClockFormatButton"> | ||||||
|  |                 <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="10" column="4"> | ||||||
|  |                <widget class="QToolButton" name="resetDefaultTimeZoneButton"> | ||||||
|                 <property name="text"> |                 <property name="text"> | ||||||
|                  <string>...</string> |                  <string>...</string> | ||||||
|                 </property> |                 </property> | ||||||
|  | @ -387,7 +429,7 @@ | ||||||
|                    <rect> |                    <rect> | ||||||
|                     <x>0</x> |                     <x>0</x> | ||||||
|                     <y>0</y> |                     <y>0</y> | ||||||
|                     <width>66</width> |                     <width>63</width> | ||||||
|                     <height>18</height> |                     <height>18</height> | ||||||
|                    </rect> |                    </rect> | ||||||
|                   </property> |                   </property> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat