Browse Source

Add validators that match validators for SettingTextField.

CURA-9793
Joey de l'Arago 2 years ago
parent
commit
9c4716416e

+ 0 - 15
resources/qml/Validators/DoubleValidator.qml

@@ -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 - 0
resources/qml/Validators/FloatValidator.qml

@@ -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 - 0
resources/qml/Validators/IntListValidator.qml

@@ -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 - 0
resources/qml/Validators/IntValidator.qml

@@ -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))
+}