1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import QtQuick 2.10
- import QtQuick.Controls 2.3
- import UM 1.3 as UM
- import Cura 1.1 as Cura
- NumericTextFieldWithUnit
- {
- id: printerHeadMinMaxField
- UM.I18nCatalog { id: catalog; name: "cura" }
- containerStackId: Cura.MachineManager.activeMachine.id
- settingKey: "machine_head_with_fans_polygon"
- settingStoreIndex: 1
- property string axisName: "x"
- property string axisMinOrMax: "min"
- property var axisValue:
- {
- if(propertyProvider.properties.value === undefined) {
- return 0;
- }
- var polygon = JSON.parse(propertyProvider.properties.value);
- var item = (axisName == "x") ? 0 : 1;
- var result = polygon[0][item];
- var func = (axisMinOrMax == "min") ? Math.min : Math.max;
- for (var i = 1; i < polygon.length; i++)
- {
- result = func(result, polygon[i][item]);
- }
- return result;
- }
- valueText: axisValue
- Connections
- {
- target: textField
- function onActiveFocusChanged()
- {
-
-
- if (!textField.activeFocus && !textField.acceptableInput)
- {
- valueText = Qt.binding(function() { return printerHeadMinMaxField.axisValue })
- }
- }
- }
- editingFinishedFunction: function()
- {
- var polygon = JSON.parse(propertyProvider.properties.value)
- var newValue = parseFloat(valueText.replace(',', '.'))
- if (axisName == "x")
- {
- var start_i1 = (axisMinOrMax == "min") ? 0 : 2
- polygon[start_i1][0] = newValue
- polygon[start_i1 + 1][0] = newValue
- }
- else
- {
- var start_i1 = (axisMinOrMax == "min") ? 1 : 0
- polygon[start_i1][1] = newValue
- polygon[start_i1 + 2][1] = newValue
- }
- var polygon_string = JSON.stringify(polygon)
- if (polygon_string != propertyProvider.properties.value)
- {
- propertyProvider.setPropertyValue("value", polygon_string)
- forceUpdateOnChangeFunction()
- }
-
- valueText = Qt.binding(function() { return axisValue })
- }
- }
|