Add validators to project.

CURA-9793
This commit is contained in:
Joey de l'Arago 2022-11-30 16:55:04 +01:00
parent 522bf60e81
commit 487bf41a7b
4 changed files with 28 additions and 1 deletions

View File

@ -119,7 +119,7 @@ UM.Dialog
text = `#${text}`;
}
}
validator: RegularExpressionValidator { regularExpression: /^#([a-fA-F0-9]{0,6})$/ }
validator: Cura.HexColorValidator {}
}
Rectangle

View File

@ -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 + "}$"
}
}

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: /^#([a-fA-F0-9]{0,6})$/
}

View File

@ -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