mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:40:05 +00:00 
			
		
		
		
	Display clock format defined in settings on map
This commit is contained in:
		
							parent
							
								
									a7cb459e20
								
							
						
					
					
						commit
						5fb9dc6a5f
					
				
					 4 changed files with 55 additions and 9 deletions
				
			
		|  | @ -52,6 +52,20 @@ public: | ||||||
|    { |    { | ||||||
|       auto& generalSettings = settings::GeneralSettings::Instance(); |       auto& generalSettings = settings::GeneralSettings::Instance(); | ||||||
| 
 | 
 | ||||||
|  |       clockFormatCallbackUuid_ = | ||||||
|  |          generalSettings.clock_format().RegisterValueChangedCallback( | ||||||
|  |             [this](const std::string&) | ||||||
|  |             { | ||||||
|  |                sweepTimeNeedsUpdate_ = true; | ||||||
|  |                Q_EMIT self_->NeedsRendering(); | ||||||
|  |             }); | ||||||
|  |       defaultTimeZoneCallbackUuid_ = | ||||||
|  |          generalSettings.default_time_zone().RegisterValueChangedCallback( | ||||||
|  |             [this](const std::string&) | ||||||
|  |             { | ||||||
|  |                sweepTimeNeedsUpdate_ = true; | ||||||
|  |                Q_EMIT self_->NeedsRendering(); | ||||||
|  |             }); | ||||||
|       showMapAttributionCallbackUuid_ = |       showMapAttributionCallbackUuid_ = | ||||||
|          generalSettings.show_map_attribution().RegisterValueChangedCallback( |          generalSettings.show_map_attribution().RegisterValueChangedCallback( | ||||||
|             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); |             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); | ||||||
|  | @ -64,6 +78,10 @@ public: | ||||||
|    { |    { | ||||||
|       auto& generalSettings = settings::GeneralSettings::Instance(); |       auto& generalSettings = settings::GeneralSettings::Instance(); | ||||||
| 
 | 
 | ||||||
|  |       generalSettings.clock_format().UnregisterValueChangedCallback( | ||||||
|  |          clockFormatCallbackUuid_); | ||||||
|  |       generalSettings.default_time_zone().UnregisterValueChangedCallback( | ||||||
|  |          defaultTimeZoneCallbackUuid_); | ||||||
|       generalSettings.show_map_attribution().UnregisterValueChangedCallback( |       generalSettings.show_map_attribution().UnregisterValueChangedCallback( | ||||||
|          showMapAttributionCallbackUuid_); |          showMapAttributionCallbackUuid_); | ||||||
|       generalSettings.show_map_logo().UnregisterValueChangedCallback( |       generalSettings.show_map_logo().UnregisterValueChangedCallback( | ||||||
|  | @ -72,6 +90,8 @@ public: | ||||||
| 
 | 
 | ||||||
|    OverlayLayer* self_; |    OverlayLayer* self_; | ||||||
| 
 | 
 | ||||||
|  |    boost::uuids::uuid clockFormatCallbackUuid_; | ||||||
|  |    boost::uuids::uuid defaultTimeZoneCallbackUuid_; | ||||||
|    boost::uuids::uuid showMapAttributionCallbackUuid_; |    boost::uuids::uuid showMapAttributionCallbackUuid_; | ||||||
|    boost::uuids::uuid showMapLogoCallbackUuid_; |    boost::uuids::uuid showMapLogoCallbackUuid_; | ||||||
| 
 | 
 | ||||||
|  | @ -263,8 +283,11 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| 
 | 
 | ||||||
|    p->sweepTimePicked_ = false; |    p->sweepTimePicked_ = false; | ||||||
| 
 | 
 | ||||||
|    if (p->sweepTimeNeedsUpdate_ && radarProductView != nullptr) |    if (radarProductView != nullptr) | ||||||
|    { |    { | ||||||
|  |       scwx::util::ClockFormat clockFormat = scwx::util::GetClockFormat( | ||||||
|  |          settings::GeneralSettings::Instance().clock_format().GetValue()); | ||||||
|  | 
 | ||||||
|       const scwx::util::time_zone* currentZone; |       const scwx::util::time_zone* currentZone; | ||||||
| 
 | 
 | ||||||
| #if defined(_MSC_VER) | #if defined(_MSC_VER) | ||||||
|  | @ -274,7 +297,7 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|       p->sweepTimeString_ = scwx::util::TimeString( |       p->sweepTimeString_ = scwx::util::TimeString( | ||||||
|          radarProductView->sweep_time(), currentZone, false); |          radarProductView->sweep_time(), clockFormat, currentZone, false); | ||||||
|       p->sweepTimeNeedsUpdate_ = false; |       p->sweepTimeNeedsUpdate_ = false; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| #include <scwx/qt/view/level3_product_view.hpp> | #include <scwx/qt/view/level3_product_view.hpp> | ||||||
|  | #include <scwx/qt/settings/general_settings.hpp> | ||||||
| #include <scwx/common/characters.hpp> | #include <scwx/common/characters.hpp> | ||||||
| #include <scwx/common/constants.hpp> | #include <scwx/common/constants.hpp> | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
|  | @ -176,6 +177,9 @@ Level3ProductView::GetDescriptionFields() const | ||||||
| 
 | 
 | ||||||
|    if (p->graphicMessage_ != nullptr) |    if (p->graphicMessage_ != nullptr) | ||||||
|    { |    { | ||||||
|  |       util::ClockFormat clockFormat = util::GetClockFormat( | ||||||
|  |          settings::GeneralSettings::Instance().clock_format().GetValue()); | ||||||
|  | 
 | ||||||
|       const scwx::util::time_zone* currentZone; |       const scwx::util::time_zone* currentZone; | ||||||
| 
 | 
 | ||||||
| #if defined(_MSC_VER) | #if defined(_MSC_VER) | ||||||
|  | @ -197,10 +201,12 @@ Level3ProductView::GetDescriptionFields() const | ||||||
| 
 | 
 | ||||||
|          description.emplace_back( |          description.emplace_back( | ||||||
|             "Volume Time", |             "Volume Time", | ||||||
|             scwx::util::TimeString(volumeTime, currentZone, false)); |             scwx::util::TimeString( | ||||||
|  |                volumeTime, clockFormat, currentZone, false)); | ||||||
|          description.emplace_back( |          description.emplace_back( | ||||||
|             "Product Time", |             "Product Time", | ||||||
|             scwx::util::TimeString(productTime, currentZone, false)); |             scwx::util::TimeString( | ||||||
|  |                productTime, clockFormat, currentZone, false)); | ||||||
| 
 | 
 | ||||||
|          description.emplace_back( |          description.emplace_back( | ||||||
|             "Sequence Number", |             "Sequence Number", | ||||||
|  |  | ||||||
|  | @ -38,6 +38,7 @@ std::chrono::system_clock::time_point TimePoint(uint32_t modifiedJulianDate, | ||||||
|                                                 uint32_t milliseconds); |                                                 uint32_t milliseconds); | ||||||
| 
 | 
 | ||||||
| std::string TimeString(std::chrono::system_clock::time_point time, | std::string TimeString(std::chrono::system_clock::time_point time, | ||||||
|  |                        ClockFormat      clockFormat = ClockFormat::_24Hour, | ||||||
|                        const time_zone* timeZone    = nullptr, |                        const time_zone* timeZone    = nullptr, | ||||||
|                        bool             epochValid  = true); |                        bool             epochValid  = true); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -49,6 +49,7 @@ std::chrono::system_clock::time_point TimePoint(uint32_t modifiedJulianDate, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::string TimeString(std::chrono::system_clock::time_point time, | std::string TimeString(std::chrono::system_clock::time_point time, | ||||||
|  |                        ClockFormat                           clockFormat, | ||||||
|                        const time_zone*                      timeZone, |                        const time_zone*                      timeZone, | ||||||
|                        bool                                  epochValid) |                        bool                                  epochValid) | ||||||
| { | { | ||||||
|  | @ -65,12 +66,27 @@ std::string TimeString(std::chrono::system_clock::time_point time, | ||||||
|    { |    { | ||||||
|       if (timeZone != nullptr) |       if (timeZone != nullptr) | ||||||
|       { |       { | ||||||
|          zoned_time zt = {current_zone(), timeInSeconds}; |          zoned_time zt = {timeZone, timeInSeconds}; | ||||||
|          os << zt; | 
 | ||||||
|  |          if (clockFormat == ClockFormat::_24Hour) | ||||||
|  |          { | ||||||
|  |             os << format("{:%Y-%m-%d %H:%M:%S %Z}", zt); | ||||||
|          } |          } | ||||||
|          else |          else | ||||||
|          { |          { | ||||||
|          os << timeInSeconds; |             os << format("{:%Y-%m-%d %I:%M:%S %p %Z}", zt); | ||||||
|  |          } | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |       { | ||||||
|  |          if (clockFormat == ClockFormat::_24Hour) | ||||||
|  |          { | ||||||
|  |             os << format("{:%Y-%m-%d %H:%M:%S %Z}", timeInSeconds); | ||||||
|  |          } | ||||||
|  |          else | ||||||
|  |          { | ||||||
|  |             os << format("{:%Y-%m-%d %I:%M:%S %p %Z}", timeInSeconds); | ||||||
|  |          } | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat