mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Mobile: Add Input Validation and Conversion for Gradient Factors.
Add input validation and input conversion for the gradient factor settings. Signed-off-by: Michael Keller <mikeller@042.ch>
This commit is contained in:
		
							parent
							
								
									704b26ff1e
								
							
						
					
					
						commit
						a946dc323b
					
				
					 1 changed files with 30 additions and 4 deletions
				
			
		|  | @ -633,8 +633,8 @@ TemplatePage { | |||
| 					} | ||||
| 				} | ||||
| 				TemplateLabel { | ||||
| 					visible: PrefTechnicalDetails.calcceiling | ||||
| 					text: qsTr("GFLow") | ||||
| 					enabled: PrefTechnicalDetails.calcceiling | ||||
| 					text: qsTr("GFLow (10 to 150)") | ||||
| 				} | ||||
| 				TemplateSpinBox { | ||||
| 					visible: PrefTechnicalDetails.calcceiling | ||||
|  | @ -645,17 +645,30 @@ TemplatePage { | |||
| 					to: 150 | ||||
| 					stepSize: 1 | ||||
| 					value: PrefTechnicalDetails.gflow | ||||
| 					validator: RegExpValidator { regExp: /1?\d{0,2}%?/ } | ||||
| 					textFromValue: function (value, locale) { | ||||
| 						return value + "%" | ||||
| 					} | ||||
| 					valueFromText: function(text, locale) { | ||||
| 						var result = parseInt(text); | ||||
| 
 | ||||
| 						if (result < 10) | ||||
| 							result = 10; | ||||
| 						else if (result > 150) | ||||
| 							result = 150; | ||||
| 						else if (isNaN(result)) | ||||
| 							result = 35; | ||||
| 
 | ||||
| 						return result; | ||||
| 					} | ||||
| 					onValueChanged: { | ||||
| 						PrefTechnicalDetails.gflow = value | ||||
| 						rootItem.settingsChanged() | ||||
| 					} | ||||
| 				} | ||||
| 				TemplateLabel { | ||||
| 					visible: PrefTechnicalDetails.calcceiling | ||||
| 					text: qsTr("GFHigh") | ||||
| 					enabled: PrefTechnicalDetails.calcceiling | ||||
| 					text: qsTr("GFHigh (10 to 150") | ||||
| 				} | ||||
| 				TemplateSpinBox { | ||||
| 					visible: PrefTechnicalDetails.calcceiling | ||||
|  | @ -666,9 +679,22 @@ TemplatePage { | |||
| 					to: 150 | ||||
| 					stepSize: 1 | ||||
| 					value: PrefTechnicalDetails.gfhigh | ||||
| 					validator: RegExpValidator { regExp: /1?\d{0,2}%?/ } | ||||
| 					textFromValue: function (value, locale) { | ||||
| 						return value + "%" | ||||
| 					} | ||||
| 					valueFromText: function(text, locale) { | ||||
| 						var result = parseInt(text); | ||||
| 
 | ||||
| 						if (result < 10) | ||||
| 							result = 10; | ||||
| 						else if (result > 150) | ||||
| 							result = 150; | ||||
| 						else if (isNaN(result)) | ||||
| 							result = 70; | ||||
| 
 | ||||
| 						return result; | ||||
| 					} | ||||
| 					onValueChanged: { | ||||
| 						PrefTechnicalDetails.gfhigh = value | ||||
| 						rootItem.settingsChanged() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue