mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 05:10:04 +00:00 
			
		
		
		
	Commit line settings changes on apply
This commit is contained in:
		
							parent
							
								
									8212d24d34
								
							
						
					
					
						commit
						6b0aaea773
					
				
					 5 changed files with 53 additions and 0 deletions
				
			
		|  | @ -68,6 +68,34 @@ void SettingsCategory::SetDefaults() | |||
|    } | ||||
| } | ||||
| 
 | ||||
| bool SettingsCategory::Commit() | ||||
| { | ||||
|    bool committed = false; | ||||
| 
 | ||||
|    // Commit subcategory arrays
 | ||||
|    for (auto& subcategoryArray : p->subcategoryArrays_) | ||||
|    { | ||||
|       for (auto& subcategory : subcategoryArray.second) | ||||
|       { | ||||
|          committed |= subcategory->Commit(); | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|    // Commit subcategories
 | ||||
|    for (auto& subcategory : p->subcategories_) | ||||
|    { | ||||
|       committed |= subcategory->Commit(); | ||||
|    } | ||||
| 
 | ||||
|    // Commit variables
 | ||||
|    for (auto& variable : p->variables_) | ||||
|    { | ||||
|       committed |= variable->Commit(); | ||||
|    } | ||||
| 
 | ||||
|    return committed; | ||||
| } | ||||
| 
 | ||||
| bool SettingsCategory::ReadJson(const boost::json::object& json) | ||||
| { | ||||
|    bool validated = true; | ||||
|  |  | |||
|  | @ -33,6 +33,15 @@ public: | |||
|     */ | ||||
|    void SetDefaults(); | ||||
| 
 | ||||
|    /**
 | ||||
|     * Sets the current value of all variables to the staged | ||||
|     * value. | ||||
|     * | ||||
|     * @return true if any staged value was committed, false if no staged values | ||||
|     * are present. | ||||
|     */ | ||||
|    bool Commit(); | ||||
| 
 | ||||
|    /**
 | ||||
|     * Reads the variables from the JSON object. | ||||
|     * | ||||
|  |  | |||
|  | @ -248,6 +248,8 @@ void AlertPaletteSettingsWidget::Impl::AddPhenomenonLine( | |||
|    layout->addWidget(lineLabel, row, 1); | ||||
|    layout->addWidget(toolButton, row, 2); | ||||
| 
 | ||||
|    self_->AddSettingsCategory(&lineSettings); | ||||
| 
 | ||||
|    connect( | ||||
|       toolButton, | ||||
|       &QAbstractButton::clicked, | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ public: | |||
|    explicit Impl() {} | ||||
|    ~Impl() = default; | ||||
| 
 | ||||
|    std::vector<settings::SettingsCategory*>      categories_; | ||||
|    std::vector<settings::SettingsInterfaceBase*> settings_; | ||||
| }; | ||||
| 
 | ||||
|  | @ -29,6 +30,12 @@ SettingsPageWidget::SettingsPageWidget(QWidget* parent) : | |||
| 
 | ||||
| SettingsPageWidget::~SettingsPageWidget() = default; | ||||
| 
 | ||||
| void SettingsPageWidget::AddSettingsCategory( | ||||
|    settings::SettingsCategory* category) | ||||
| { | ||||
|    p->categories_.push_back(category); | ||||
| } | ||||
| 
 | ||||
| void SettingsPageWidget::AddSettingsInterface( | ||||
|    settings::SettingsInterfaceBase* setting) | ||||
| { | ||||
|  | @ -39,6 +46,11 @@ bool SettingsPageWidget::CommitChanges() | |||
| { | ||||
|    bool committed = false; | ||||
| 
 | ||||
|    for (auto& category : p->categories_) | ||||
|    { | ||||
|       committed |= category->Commit(); | ||||
|    } | ||||
| 
 | ||||
|    for (auto& setting : p->settings_) | ||||
|    { | ||||
|       committed |= setting->Commit(); | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/qt/settings/settings_category.hpp> | ||||
| #include <scwx/qt/settings/settings_interface_base.hpp> | ||||
| 
 | ||||
| #include <QWidget> | ||||
|  | @ -59,6 +60,7 @@ public: | |||
|    void ResetToDefault(); | ||||
| 
 | ||||
| protected: | ||||
|    void AddSettingsCategory(settings::SettingsCategory* category); | ||||
|    void AddSettingsInterface(settings::SettingsInterfaceBase* setting); | ||||
| 
 | ||||
| private: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat