diff --git a/resources/qml/ColorDialog.qml b/resources/qml/ColorDialog.qml index e5216a3404..94416d77d2 100644 --- a/resources/qml/ColorDialog.qml +++ b/resources/qml/ColorDialog.qml @@ -119,7 +119,7 @@ UM.Dialog text = `#${text}`; } } - validator: RegularExpressionValidator { regularExpression: /^#([a-fA-F0-9]{0,6})$/ } + validator: Cura.HexColorValidator {} } Rectangle diff --git a/resources/qml/Validators/DoubleValidator.qml b/resources/qml/Validators/DoubleValidator.qml new file mode 100644 index 0000000000..dc92dbd1ae --- /dev/null +++ b/resources/qml/Validators/DoubleValidator.qml @@ -0,0 +1,15 @@ +// 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 + "}$" + } +} \ No newline at end of file diff --git a/resources/qml/Validators/HexColorValidator.qml b/resources/qml/Validators/HexColorValidator.qml new file mode 100644 index 0000000000..2c3ba706ec --- /dev/null +++ b/resources/qml/Validators/HexColorValidator.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: /^#([a-fA-F0-9]{0,6})$/ +} \ No newline at end of file diff --git a/resources/qml/qmldir b/resources/qml/qmldir index dd594d8583..9eee76eda7 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -19,6 +19,9 @@ SettingView 1.0 SettingView.qml ProfileMenu 1.0 ProfileMenu.qml PrintSelectorCard 1.0 PrintSelectorCard.qml +# Cura/Validators +DoubleValidator 1.7 DoubleValidator.qml +HexColorValidator 1.7 HexColorValidator.qml # Cura/WelcomePages @@ -42,6 +45,7 @@ SingleSettingExtruderSelectorBar 1.7 SingleSettingExtruderSelectorBar.qml ExtruderButton 1.7 ExtruderButton.qml SingleSettingComboBox 1.7 SingleSettingComboBox.qml SingleSettingSlider 1.7 SingleSettingSlider.qml +SingleSettingTextFieldWithUnit 1.7 SingleSettingTextFieldWithUnit.qml # Cura/MachineSettings