Fix an error that makes Cura crash when introducing commas in the

textfields in the ImageReader panel. Now it's possible to use commas xor
dots for separating decimal values.
This commit is contained in:
Diego Prado Gesto 2017-12-01 14:26:53 +01:00
parent c039535ee3
commit 21d61ce21e
2 changed files with 9 additions and 12 deletions

View file

@ -43,7 +43,7 @@ UM.Dialog
TextField { TextField {
id: peak_height id: peak_height
objectName: "Peak_Height" objectName: "Peak_Height"
validator: DoubleValidator {notation: DoubleValidator.StandardNotation; bottom: -500; top: 500;} validator: RegExpValidator {regExp: /^-?\d{1,3}([\,|\.]\d*)?$/}
width: 180 * screenScaleFactor width: 180 * screenScaleFactor
onTextChanged: { manager.onPeakHeightChanged(text) } onTextChanged: { manager.onPeakHeightChanged(text) }
} }
@ -66,7 +66,7 @@ UM.Dialog
TextField { TextField {
id: base_height id: base_height
objectName: "Base_Height" objectName: "Base_Height"
validator: DoubleValidator {notation: DoubleValidator.StandardNotation; bottom: 0; top: 500;} validator: RegExpValidator {regExp: /^\d{1,3}([\,|\.]\d*)?$/}
width: 180 * screenScaleFactor width: 180 * screenScaleFactor
onTextChanged: { manager.onBaseHeightChanged(text) } onTextChanged: { manager.onBaseHeightChanged(text) }
} }
@ -90,7 +90,7 @@ UM.Dialog
id: width id: width
objectName: "Width" objectName: "Width"
focus: true focus: true
validator: DoubleValidator {notation: DoubleValidator.StandardNotation; bottom: 1; top: 500;} validator: RegExpValidator {regExp: /^[1-9]\d{0,2}([\,|\.]\d*)?$/}
width: 180 * screenScaleFactor width: 180 * screenScaleFactor
onTextChanged: { manager.onWidthChanged(text) } onTextChanged: { manager.onWidthChanged(text) }
} }
@ -113,7 +113,7 @@ UM.Dialog
id: depth id: depth
objectName: "Depth" objectName: "Depth"
focus: true focus: true
validator: DoubleValidator {notation: DoubleValidator.StandardNotation; bottom: 1; top: 500;} validator: RegExpValidator {regExp: /^[1-9]\d{0,2}([\,|\.]\d*)?$/}
width: 180 * screenScaleFactor width: 180 * screenScaleFactor
onTextChanged: { manager.onDepthChanged(text) } onTextChanged: { manager.onDepthChanged(text) }
} }

View file

@ -107,7 +107,7 @@ class ImageReaderUI(QObject):
def onWidthChanged(self, value): def onWidthChanged(self, value):
if self._ui_view and not self._disable_size_callbacks: if self._ui_view and not self._disable_size_callbacks:
if len(value) > 0: if len(value) > 0:
self._width = float(value) self._width = float(value.replace(",", "."))
else: else:
self._width = 0 self._width = 0
@ -120,7 +120,7 @@ class ImageReaderUI(QObject):
def onDepthChanged(self, value): def onDepthChanged(self, value):
if self._ui_view and not self._disable_size_callbacks: if self._ui_view and not self._disable_size_callbacks:
if len(value) > 0: if len(value) > 0:
self._depth = float(value) self._depth = float(value.replace(",", "."))
else: else:
self._depth = 0 self._depth = 0
@ -132,14 +132,14 @@ class ImageReaderUI(QObject):
@pyqtSlot(str) @pyqtSlot(str)
def onBaseHeightChanged(self, value): def onBaseHeightChanged(self, value):
if (len(value) > 0): if (len(value) > 0):
self.base_height = float(value) self.base_height = float(value.replace(",", "."))
else: else:
self.base_height = 0 self.base_height = 0
@pyqtSlot(str) @pyqtSlot(str)
def onPeakHeightChanged(self, value): def onPeakHeightChanged(self, value):
if (len(value) > 0): if (len(value) > 0):
self.peak_height = float(value) self.peak_height = float(value.replace(",", "."))
else: else:
self.peak_height = 0 self.peak_height = 0
@ -149,7 +149,4 @@ class ImageReaderUI(QObject):
@pyqtSlot(int) @pyqtSlot(int)
def onImageColorInvertChanged(self, value): def onImageColorInvertChanged(self, value):
if (value == 1): self.image_color_invert = (value == 1)
self.image_color_invert = True
else:
self.image_color_invert = False