mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 20:30:05 +00:00 
			
		
		
		
	Add whitespace trimming to some settings
This commit is contained in:
		
							parent
							
								
									67706dc186
								
							
						
					
					
						commit
						25fb9bdae0
					
				
					 3 changed files with 25 additions and 1 deletions
				
			
		|  | @ -56,6 +56,8 @@ public: | |||
|    double                     unitScale_ {1}; | ||||
|    std::optional<std::string> unitAbbreviation_ {}; | ||||
|    bool                       unitEnabled_ {false}; | ||||
| 
 | ||||
|    bool trimmingEnabled_ {false}; | ||||
| }; | ||||
| 
 | ||||
| template<class T> | ||||
|  | @ -191,8 +193,11 @@ void SettingsInterface<T>::SetEditWidget(QWidget* widget) | |||
|                           p->context_.get(), | ||||
|                           [this](const QString& text) | ||||
|                           { | ||||
|                              QString trimmedText = | ||||
|                                 p->trimmingEnabled_ ? text.trimmed() : text; | ||||
| 
 | ||||
|                              // Map to value if required
 | ||||
|                              std::string value {text.toStdString()}; | ||||
|                              std::string value {trimmedText.toStdString()}; | ||||
|                              if (p->mapToValue_ != nullptr) | ||||
|                              { | ||||
|                                 value = p->mapToValue_(value); | ||||
|  | @ -488,6 +493,12 @@ void SettingsInterface<T>::SetUnit(const double&      scale, | |||
|    p->UpdateUnitLabel(); | ||||
| } | ||||
| 
 | ||||
| template<class T> | ||||
| void SettingsInterface<T>::EnableTrimming(bool trimmingEnabled) | ||||
| { | ||||
|    p->trimmingEnabled_ = trimmingEnabled; | ||||
| } | ||||
| 
 | ||||
| template<class T> | ||||
| template<class U> | ||||
| void SettingsInterface<T>::Impl::SetWidgetText(U* widget, const T& currentValue) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AdenKoperczak
						AdenKoperczak