mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-19 00:05:56 +08:00
Merge branch '2.3' of github.com:Ultimaker/Cura into 2.3
This commit is contained in:
commit
78ab1f1a71
@ -28,7 +28,7 @@ class MachineNameValidator(QObject):
|
|||||||
# special character, and that up to [machine_name_max_length / 12] times.
|
# special character, and that up to [machine_name_max_length / 12] times.
|
||||||
maximum_special_characters = int(machine_name_max_length / 12)
|
maximum_special_characters = int(machine_name_max_length / 12)
|
||||||
unescaped = r"[a-zA-Z0-9_\-\.\/]"
|
unescaped = r"[a-zA-Z0-9_\-\.\/]"
|
||||||
self.machine_name_regex = r"((" + unescaped + "){0,12}|.){0," + str(maximum_special_characters) + r"}"
|
self.machine_name_regex = r"^((" + unescaped + "){0,12}|.){0," + str(maximum_special_characters) + r"}$"
|
||||||
|
|
||||||
validationChanged = pyqtSignal()
|
validationChanged = pyqtSignal()
|
||||||
|
|
||||||
@ -56,14 +56,11 @@ class MachineNameValidator(QObject):
|
|||||||
def updateValidation(self, new_name):
|
def updateValidation(self, new_name):
|
||||||
is_valid = self.validate(new_name, 0)
|
is_valid = self.validate(new_name, 0)
|
||||||
if is_valid == QValidator.Acceptable:
|
if is_valid == QValidator.Acceptable:
|
||||||
print("VALID")
|
|
||||||
self.validation_regex = "^.*$" #Matches anything.
|
self.validation_regex = "^.*$" #Matches anything.
|
||||||
else:
|
else:
|
||||||
print("BROKEN!")
|
|
||||||
self.validation_regex = "a^" #Never matches (unless you manage to get "a" before the start of the string... good luck).
|
self.validation_regex = "a^" #Never matches (unless you manage to get "a" before the start of the string... good luck).
|
||||||
self.validationChanged.emit()
|
self.validationChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty("QRegExp", notify=validationChanged)
|
@pyqtProperty("QRegExp", notify=validationChanged)
|
||||||
def machineNameRegex(self):
|
def machineNameRegex(self):
|
||||||
print(self.machine_name_regex)
|
|
||||||
return QRegExp(self.machine_name_regex)
|
return QRegExp(self.machine_name_regex)
|
@ -251,6 +251,8 @@ UM.ManagementPage
|
|||||||
{
|
{
|
||||||
id: renameDialog;
|
id: renameDialog;
|
||||||
object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
|
object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
|
||||||
|
property var machine_name_validator: Cura.MachineNameValidator { }
|
||||||
|
validName: renameDialog.newName.match(renameDialog.machine_name_validator.machineNameRegex) != null;
|
||||||
onAccepted:
|
onAccepted:
|
||||||
{
|
{
|
||||||
Cura.MachineManager.renameMachine(base.currentItem.id, newName.trim());
|
Cura.MachineManager.renameMachine(base.currentItem.id, newName.trim());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user