mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:30:05 +00:00 
			
		
		
		
	Refactor clock format to wxdata
This commit is contained in:
		
							parent
							
								
									bb287dad9c
								
							
						
					
					
						commit
						a7cb459e20
					
				
					 6 changed files with 42 additions and 33 deletions
				
			
		|  | @ -5,6 +5,7 @@ | |||
| #include <scwx/qt/types/alert_types.hpp> | ||||
| #include <scwx/qt/types/qt_types.hpp> | ||||
| #include <scwx/qt/types/time_types.hpp> | ||||
| #include <scwx/util/time.hpp> | ||||
| 
 | ||||
| #include <array> | ||||
| 
 | ||||
|  | @ -25,7 +26,7 @@ public: | |||
|    explicit Impl() | ||||
|    { | ||||
|       std::string defaultClockFormatValue = | ||||
|          types::GetClockFormatName(types::ClockFormat::_24Hour); | ||||
|          scwx::util::GetClockFormatName(scwx::util::ClockFormat::_24Hour); | ||||
|       std::string defaultDefaultAlertActionValue = | ||||
|          types::GetAlertActionName(types::AlertAction::Go); | ||||
|       std::string defaultDefaultTimeZoneValue = | ||||
|  | @ -78,9 +79,9 @@ public: | |||
|       loopTime_.SetMaximum(1440); | ||||
| 
 | ||||
|       clockFormat_.SetValidator( | ||||
|          SCWX_SETTINGS_ENUM_VALIDATOR(types::ClockFormat, | ||||
|                                       types::ClockFormatIterator(), | ||||
|                                       types::GetClockFormatName)); | ||||
|          SCWX_SETTINGS_ENUM_VALIDATOR(scwx::util::ClockFormat, | ||||
|                                       scwx::util::ClockFormatIterator(), | ||||
|                                       scwx::util::GetClockFormatName)); | ||||
|       defaultAlertAction_.SetValidator( | ||||
|          SCWX_SETTINGS_ENUM_VALIDATOR(types::AlertAction, | ||||
|                                       types::AlertActionIterator(), | ||||
|  |  | |||
|  | @ -12,24 +12,12 @@ namespace qt | |||
| namespace types | ||||
| { | ||||
| 
 | ||||
| static const std::unordered_map<ClockFormat, std::string> clockFormatName_ { | ||||
|    {ClockFormat::_12Hour, "12-hour"}, | ||||
|    {ClockFormat::_24Hour, "24-hour"}, | ||||
|    {ClockFormat::Unknown, "?"}}; | ||||
| 
 | ||||
| static const std::unordered_map<DefaultTimeZone, std::string> | ||||
|    defaultTimeZoneName_ {{DefaultTimeZone::Local, "Local"}, | ||||
|                          {DefaultTimeZone::Radar, "Radar"}, | ||||
|                          {DefaultTimeZone::UTC, "UTC"}, | ||||
|                          {DefaultTimeZone::Unknown, "?"}}; | ||||
| 
 | ||||
| SCWX_GET_ENUM(ClockFormat, GetClockFormat, clockFormatName_) | ||||
| 
 | ||||
| const std::string& GetClockFormatName(ClockFormat clockFormat) | ||||
| { | ||||
|    return clockFormatName_.at(clockFormat); | ||||
| } | ||||
| 
 | ||||
| SCWX_GET_ENUM(DefaultTimeZone, GetDefaultTimeZone, defaultTimeZoneName_) | ||||
| 
 | ||||
| const std::string& GetDefaultTimeZoneName(DefaultTimeZone timeZone) | ||||
|  |  | |||
|  | @ -11,16 +11,6 @@ namespace qt | |||
| namespace types | ||||
| { | ||||
| 
 | ||||
| enum class ClockFormat | ||||
| { | ||||
|    _12Hour, | ||||
|    _24Hour, | ||||
|    Unknown | ||||
| }; | ||||
| typedef scwx::util:: | ||||
|    Iterator<ClockFormat, ClockFormat::_12Hour, ClockFormat::_24Hour> | ||||
|       ClockFormatIterator; | ||||
| 
 | ||||
| enum class DefaultTimeZone | ||||
| { | ||||
|    Local, | ||||
|  | @ -32,8 +22,6 @@ typedef scwx::util:: | |||
|    Iterator<DefaultTimeZone, DefaultTimeZone::Local, DefaultTimeZone::UTC> | ||||
|       DefaultTimeZoneIterator; | ||||
| 
 | ||||
| ClockFormat        GetClockFormat(const std::string& name); | ||||
| const std::string& GetClockFormatName(ClockFormat clockFormat); | ||||
| DefaultTimeZone    GetDefaultTimeZone(const std::string& name); | ||||
| const std::string& GetDefaultTimeZoneName(DefaultTimeZone timeZone); | ||||
| 
 | ||||
|  |  | |||
|  | @ -608,17 +608,17 @@ void SettingsDialogImpl::SetupGeneralTab() | |||
|    defaultAlertAction_.SetEditWidget(self_->ui->defaultAlertActionComboBox); | ||||
|    defaultAlertAction_.SetResetButton(self_->ui->resetDefaultAlertActionButton); | ||||
| 
 | ||||
|    for (const auto& clockFormat : types::ClockFormatIterator()) | ||||
|    for (const auto& clockFormat : scwx::util::ClockFormatIterator()) | ||||
|    { | ||||
|       self_->ui->clockFormatComboBox->addItem( | ||||
|          QString::fromStdString(types::GetClockFormatName(clockFormat))); | ||||
|          QString::fromStdString(scwx::util::GetClockFormatName(clockFormat))); | ||||
|    } | ||||
| 
 | ||||
|    clockFormat_.SetSettingsVariable(generalSettings.clock_format()); | ||||
|    clockFormat_.SetMapFromValueFunction( | ||||
|       SCWX_ENUM_MAP_FROM_VALUE(types::ClockFormat, | ||||
|                                types::ClockFormatIterator(), | ||||
|                                types::GetClockFormatName)); | ||||
|       SCWX_ENUM_MAP_FROM_VALUE(scwx::util::ClockFormat, | ||||
|                                scwx::util::ClockFormatIterator(), | ||||
|                                scwx::util::GetClockFormatName)); | ||||
|    clockFormat_.SetMapToValueFunction( | ||||
|       [](std::string text) -> std::string | ||||
|       { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat