mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:40:06 +00:00 
			
		
		
		
	Add storm tracking information to settings
This commit is contained in:
		
							parent
							
								
									5b9df2b61a
								
							
						
					
					
						commit
						5e0f69018b
					
				
					 5 changed files with 128 additions and 1 deletions
				
			
		
							
								
								
									
										75
									
								
								scwx-qt/source/scwx/qt/settings/product_settings.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								scwx-qt/source/scwx/qt/settings/product_settings.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,75 @@ | |||
| #include <scwx/qt/settings/product_settings.hpp> | ||||
| #include <scwx/qt/settings/settings_container.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace settings | ||||
| { | ||||
| 
 | ||||
| static const std::string logPrefix_ = "scwx::qt::settings::product_settings"; | ||||
| 
 | ||||
| class ProductSettings::Impl | ||||
| { | ||||
| public: | ||||
|    explicit Impl() | ||||
|    { | ||||
|       stiForecastEnabled_.SetDefault(true); | ||||
|       stiPastEnabled_.SetDefault(true); | ||||
|    } | ||||
| 
 | ||||
|    ~Impl() {} | ||||
| 
 | ||||
|    SettingsVariable<bool> stiForecastEnabled_ {"sti_forecast_enabled"}; | ||||
|    SettingsVariable<bool> stiPastEnabled_ {"sti_past_enabled"}; | ||||
| }; | ||||
| 
 | ||||
| ProductSettings::ProductSettings() : | ||||
|     SettingsCategory("product"), p(std::make_unique<Impl>()) | ||||
| { | ||||
|    RegisterVariables({&p->stiForecastEnabled_, &p->stiPastEnabled_}); | ||||
|    SetDefaults(); | ||||
| } | ||||
| ProductSettings::~ProductSettings() = default; | ||||
| 
 | ||||
| ProductSettings::ProductSettings(ProductSettings&&) noexcept = default; | ||||
| ProductSettings& | ||||
| ProductSettings::operator=(ProductSettings&&) noexcept = default; | ||||
| 
 | ||||
| SettingsVariable<bool>& ProductSettings::sti_forecast_enabled() const | ||||
| { | ||||
|    return p->stiForecastEnabled_; | ||||
| } | ||||
| 
 | ||||
| SettingsVariable<bool>& ProductSettings::sti_past_enabled() const | ||||
| { | ||||
|    return p->stiPastEnabled_; | ||||
| } | ||||
| 
 | ||||
| bool ProductSettings::Shutdown() | ||||
| { | ||||
|    bool dataChanged = false; | ||||
| 
 | ||||
|    // Commit settings that are managed separate from the settings dialog
 | ||||
|    dataChanged |= p->stiForecastEnabled_.Commit(); | ||||
|    dataChanged |= p->stiPastEnabled_.Commit(); | ||||
| 
 | ||||
|    return dataChanged; | ||||
| } | ||||
| 
 | ||||
| ProductSettings& ProductSettings::Instance() | ||||
| { | ||||
|    static ProductSettings generalSettings_; | ||||
|    return generalSettings_; | ||||
| } | ||||
| 
 | ||||
| bool operator==(const ProductSettings& lhs, const ProductSettings& rhs) | ||||
| { | ||||
|    return (lhs.p->stiForecastEnabled_ == rhs.p->stiForecastEnabled_ && | ||||
|            lhs.p->stiPastEnabled_ == rhs.p->stiPastEnabled_); | ||||
| } | ||||
| 
 | ||||
| } // namespace settings
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
							
								
								
									
										45
									
								
								scwx-qt/source/scwx/qt/settings/product_settings.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								scwx-qt/source/scwx/qt/settings/product_settings.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/qt/settings/settings_category.hpp> | ||||
| #include <scwx/qt/settings/settings_variable.hpp> | ||||
| 
 | ||||
| #include <memory> | ||||
| #include <string> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace settings | ||||
| { | ||||
| 
 | ||||
| class ProductSettings : public SettingsCategory | ||||
| { | ||||
| public: | ||||
|    explicit ProductSettings(); | ||||
|    ~ProductSettings(); | ||||
| 
 | ||||
|    ProductSettings(const ProductSettings&)            = delete; | ||||
|    ProductSettings& operator=(const ProductSettings&) = delete; | ||||
| 
 | ||||
|    ProductSettings(ProductSettings&&) noexcept; | ||||
|    ProductSettings& operator=(ProductSettings&&) noexcept; | ||||
| 
 | ||||
|    SettingsVariable<bool>& sti_forecast_enabled() const; | ||||
|    SettingsVariable<bool>& sti_past_enabled() const; | ||||
| 
 | ||||
|    static ProductSettings& Instance(); | ||||
| 
 | ||||
|    friend bool operator==(const ProductSettings& lhs, | ||||
|                           const ProductSettings& rhs); | ||||
| 
 | ||||
|    bool Shutdown(); | ||||
| 
 | ||||
| private: | ||||
|    class Impl; | ||||
|    std::unique_ptr<Impl> p; | ||||
| }; | ||||
| 
 | ||||
| } // namespace settings
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat