mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 20:28:01 -06:00
Update validators for SettingTextField to use strings from our validators. You can't access the components directly from javascript without instantiating them so they are instantiated here first.
CURA-9793
This commit is contained in:
parent
1e6184448c
commit
c6cc9ee6ec
1 changed files with 21 additions and 2 deletions
|
@ -4,7 +4,7 @@
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
|
|
||||||
import UM 1.5 as UM
|
import UM 1.7 as UM
|
||||||
|
|
||||||
SettingItem
|
SettingItem
|
||||||
{
|
{
|
||||||
|
@ -159,7 +159,26 @@ SettingItem
|
||||||
// should be done as little as possible)
|
// should be done as little as possible)
|
||||||
clip: definition.type == "str" || definition.type == "[int]"
|
clip: definition.type == "str" || definition.type == "[int]"
|
||||||
|
|
||||||
validator: RegularExpressionValidator { regularExpression: (definition.type == "[int]") ? /^\[?(\s*-?[0-9]{0,11}\s*,)*(\s*-?[0-9]{0,11})\s*\]?$/ : (definition.type == "int") ? /^-?[0-9]{0,12}$/ : (definition.type == "float") ? /^-?[0-9]{0,11}[.,]?[0-9]{0,3}$/ : /^.*$/ } // definition.type property from parent loader used to disallow fractional number entry
|
readonly property UM.IntValidator intValidator: UM.IntValidator {}
|
||||||
|
readonly property UM.FloatValidator floatValidator: UM.FloatValidator {}
|
||||||
|
readonly property UM.IntListValidator intListValidator: UM.IntListValidator {}
|
||||||
|
validator: RegularExpressionValidator
|
||||||
|
{
|
||||||
|
regularExpression:
|
||||||
|
{
|
||||||
|
switch (definition.type)
|
||||||
|
{
|
||||||
|
case "[int]":
|
||||||
|
return new RegExp(intListValidator.regexString)
|
||||||
|
case "int":
|
||||||
|
return new RegExp(intValidator.regexString)
|
||||||
|
case "float":
|
||||||
|
return new RegExp(floatValidator.regexString)
|
||||||
|
default:
|
||||||
|
return new RegExp("^.*$")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Binding
|
Binding
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue