Add validators that match validators for SettingTextField.

CURA-9793
This commit is contained in:
Joey de l'Arago 2022-12-01 16:58:29 +01:00
parent 01ebee4aea
commit 9c4716416e
4 changed files with 29 additions and 15 deletions

View File

@ -1,15 +0,0 @@
// Copyright (c) 2022 UltiMaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.15
RegularExpressionValidator
{
property int maxBeforeDecimal: 10
property int maxAfterDecimal: 10
regularExpression:
{
// The build in DoubleValidator doesn't handle "," and "." interchangably.
return "^-?[0-9]{0," + maxBeforeDecimal + "}[.,]?[0-9]{0," + maxAfterDecimal + "}$"
}
}

View File

@ -0,0 +1,11 @@
// Copyright (c) 2022 UltiMaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.15
RegularExpressionValidator
{
property int maxBeforeDecimal: 11
property int maxAfterDecimal: 3
regularExpression: new RegExp("^-?[0-9]{0,%0}[.,]?[0-9]{0,%1}$".arg(maxBeforeDecimal).arg(maxAfterDecimal))
}

View File

@ -0,0 +1,8 @@
// Copyright (c) 2022 UltiMaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.15
RegularExpressionValidator
{
regularExpression: new RegExp("^\[?(\s*-?[0-9]{0,11}\s*,)*(\s*-?[0-9]{0,11})\s*\]?$")
}

View File

@ -0,0 +1,10 @@
// Copyright (c) 2022 UltiMaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.15
RegularExpressionValidator
{
property int maxNumbers: 12
regularExpression: new RegExp("^-?[0-9]{0,%0}$".arg(maxNumbers))
}