From f6012293907f8e930ebb3a8c65459381e8785fa5 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 16:27:42 +0100 Subject: [PATCH] Move Validators to UM, so they can be used in UM components. Update all TextFieldWithUnit to use our FloatValidator. This component now has proper styling when the input is invalid. The DoubleValidator was flagging numbers with a "." in them as an incorrect input (I assume this is because the region was set to europe on the OS where "," is common). The workaround is to use our FloatValidator which validates both "." and "," CURA-9793 --- resources/qml/ColorDialog.qml | 8 ++++---- .../Recommended/RecommendedStrengthSelector.qml | 4 ++-- resources/qml/Validators/FloatValidator.qml | 12 ------------ resources/qml/Validators/HexColorValidator.qml | 9 --------- resources/qml/Validators/IntListValidator.qml | 9 --------- resources/qml/Validators/IntValidator.qml | 11 ----------- resources/qml/qmldir | 6 ------ 7 files changed, 6 insertions(+), 53 deletions(-) delete mode 100644 resources/qml/Validators/FloatValidator.qml delete mode 100644 resources/qml/Validators/HexColorValidator.qml delete mode 100644 resources/qml/Validators/IntListValidator.qml delete mode 100644 resources/qml/Validators/IntValidator.qml diff --git a/resources/qml/ColorDialog.qml b/resources/qml/ColorDialog.qml index 94416d77d2..36da26158d 100644 --- a/resources/qml/ColorDialog.qml +++ b/resources/qml/ColorDialog.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Ultimaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.15 @@ -6,8 +6,8 @@ import QtQuick.Controls 2.2 import QtQuick.Window 2.1 import QtQuick.Layouts 1.1 -import UM 1.5 as UM -import Cura 1.1 as Cura +import UM 1.7 as UM +import Cura 1.7 as Cura /* @@ -119,7 +119,7 @@ UM.Dialog text = `#${text}`; } } - validator: Cura.HexColorValidator {} + validator: UM.HexColorValidator {} } Rectangle diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 086f9a7728..4adca95102 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -81,7 +81,7 @@ RecommendedSettingSection width: parent.width settingName: "wall_thickness" updateAllExtruders: true - validator: Cura.FloatValidator {} + validator: UM.FloatValidator {} unitText: catalog.i18nc("@label", "mm") } } @@ -94,7 +94,7 @@ RecommendedSettingSection width: parent.width settingName: "top_bottom_thickness" updateAllExtruders: true - validator: Cura.FloatValidator {} + validator: UM.FloatValidator {} unitText: catalog.i18nc("@label", "mm") } } diff --git a/resources/qml/Validators/FloatValidator.qml b/resources/qml/Validators/FloatValidator.qml deleted file mode 100644 index 55f2fbae00..0000000000 --- a/resources/qml/Validators/FloatValidator.qml +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2022 UltiMaker -// 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)) -} \ No newline at end of file diff --git a/resources/qml/Validators/HexColorValidator.qml b/resources/qml/Validators/HexColorValidator.qml deleted file mode 100644 index 4a15000b8a..0000000000 --- a/resources/qml/Validators/HexColorValidator.qml +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2022 UltiMaker -// 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/Validators/IntListValidator.qml b/resources/qml/Validators/IntListValidator.qml deleted file mode 100644 index f0b9d790e2..0000000000 --- a/resources/qml/Validators/IntListValidator.qml +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2022 UltiMaker -// 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*\]?$") -} \ No newline at end of file diff --git a/resources/qml/Validators/IntValidator.qml b/resources/qml/Validators/IntValidator.qml deleted file mode 100644 index 29b04ea94c..0000000000 --- a/resources/qml/Validators/IntValidator.qml +++ /dev/null @@ -1,11 +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 maxNumbers: 12 - - regularExpression: new RegExp("^-?[0-9]{0,%0}$".arg(maxNumbers)) -} \ No newline at end of file diff --git a/resources/qml/qmldir b/resources/qml/qmldir index 109cbc0823..8fce82c858 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -19,12 +19,6 @@ SettingView 1.0 SettingView.qml ProfileMenu 1.0 ProfileMenu.qml PrintSelectorCard 1.0 PrintSelectorCard.qml -# Cura/Validators -FloatValidator 1.7 FloatValidator.qml -IntValidator 1.7 IntValidator -IntListValidator 1.7 IntListValidator -HexColorValidator 1.7 HexColorValidator.qml - # Cura/WelcomePages WizardPanel 1.0 WizardPanel.qml