mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-16 11:55:54 +08:00
Add validators that match validators for SettingTextField.
CURA-9793
This commit is contained in:
parent
01ebee4aea
commit
9c4716416e
@ -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 + "}$"
|
||||
}
|
||||
}
|
11
resources/qml/Validators/FloatValidator.qml
Normal file
11
resources/qml/Validators/FloatValidator.qml
Normal 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))
|
||||
}
|
8
resources/qml/Validators/IntListValidator.qml
Normal file
8
resources/qml/Validators/IntListValidator.qml
Normal 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*\]?$")
|
||||
}
|
10
resources/qml/Validators/IntValidator.qml
Normal file
10
resources/qml/Validators/IntValidator.qml
Normal 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))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user