MaterialView.qml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Uranium is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 1.3
  5. import QtQuick.Dialogs 1.2
  6. import UM 1.2 as UM
  7. import Cura 1.0 as Cura
  8. TabView
  9. {
  10. id: base
  11. property QtObject properties;
  12. property bool editingEnabled: false;
  13. property string currency: UM.Preferences.getValue("general/currency") ? UM.Preferences.getValue("general/currency") : "€"
  14. property real firstColumnWidth: width * 0.45
  15. property real secondColumnWidth: width * 0.45
  16. property string containerId: ""
  17. Tab
  18. {
  19. title: "Information"
  20. anchors
  21. {
  22. leftMargin: UM.Theme.getSize("default_margin").width
  23. topMargin: UM.Theme.getSize("default_margin").height
  24. bottomMargin: UM.Theme.getSize("default_margin").height
  25. rightMargin: 0
  26. }
  27. ScrollView
  28. {
  29. anchors.fill: parent
  30. horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
  31. Flow
  32. {
  33. id: containerGrid
  34. width: base.width;
  35. property real rowHeight: textField.height;
  36. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") }
  37. ReadOnlyTextField
  38. {
  39. id: textField;
  40. width: base.secondColumnWidth;
  41. text: properties.supplier;
  42. readOnly: !base.editingEnabled;
  43. onEditingFinished: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "brand", text)
  44. }
  45. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") }
  46. ReadOnlyTextField
  47. {
  48. width: base.secondColumnWidth;
  49. text: properties.material_type;
  50. readOnly: !base.editingEnabled;
  51. onEditingFinished: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "material", text)
  52. }
  53. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") }
  54. Row
  55. {
  56. width: base.secondColumnWidth;
  57. height: parent.rowHeight;
  58. spacing: UM.Theme.getSize("default_margin").width/2
  59. Rectangle
  60. {
  61. id: colorSelector
  62. color: properties.color_code
  63. onColorChanged: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "color_code", color)
  64. width: colorLabel.height * 0.75
  65. height: colorLabel.height * 0.75
  66. border.width: UM.Theme.getSize("default_lining").height
  67. anchors.verticalCenter: parent.verticalCenter
  68. MouseArea { anchors.fill: parent; onClicked: colorDialog.open(); enabled: base.editingEnabled }
  69. }
  70. ReadOnlyTextField
  71. {
  72. id: colorLabel;
  73. text: properties.color_name;
  74. readOnly: !base.editingEnabled
  75. onEditingFinished: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "color_name", text)
  76. }
  77. ColorDialog { id: colorDialog; color: properties.color_code; onAccepted: colorSelector.color = color }
  78. }
  79. Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
  80. Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: "<b>" + catalog.i18nc("@label", "Properties") + "</b>" }
  81. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") }
  82. ReadOnlySpinBox
  83. {
  84. width: base.secondColumnWidth;
  85. value: properties.density;
  86. decimals: 2
  87. suffix: "g/cm"
  88. stepSize: 0.01
  89. readOnly: !base.editingEnabled;
  90. onEditingFinished: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "properties/density", value)
  91. }
  92. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") }
  93. ReadOnlySpinBox
  94. {
  95. width: base.secondColumnWidth;
  96. value: properties.diameter;
  97. decimals: 2
  98. suffix: "mm³"
  99. stepSize: 0.01
  100. readOnly: !base.editingEnabled;
  101. onEditingFinished: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "properties/diameter", value)
  102. }
  103. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") }
  104. SpinBox
  105. {
  106. width: base.secondColumnWidth;
  107. value: properties.spool_cost;
  108. prefix: base.currency
  109. enabled: false
  110. }
  111. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") }
  112. SpinBox
  113. {
  114. width: base.secondColumnWidth;
  115. value: properties.spool_weight;
  116. suffix: "g";
  117. stepSize: 10
  118. enabled: false
  119. }
  120. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") }
  121. SpinBox
  122. {
  123. width: base.secondColumnWidth;
  124. value: parseFloat(properties.spool_length);
  125. suffix: "m";
  126. enabled: false
  127. }
  128. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter (Approx.)") }
  129. SpinBox
  130. {
  131. width: base.secondColumnWidth;
  132. value: parseFloat(properties.cost_per_meter);
  133. suffix: catalog.i18nc("@label", "%1/m".arg(base.currency));
  134. enabled: false
  135. }
  136. Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
  137. Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Description") }
  138. ReadOnlyTextArea
  139. {
  140. text: properties.description;
  141. width: base.firstColumnWidth + base.secondColumnWidth
  142. wrapMode: Text.WordWrap
  143. readOnly: !base.editingEnabled;
  144. onEditingFinished: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "description", text)
  145. }
  146. Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Adhesion Information") }
  147. ReadOnlyTextArea
  148. {
  149. text: properties.adhesion_info;
  150. width: base.firstColumnWidth + base.secondColumnWidth
  151. wrapMode: Text.WordWrap
  152. readOnly: !base.editingEnabled;
  153. onEditingFinished: Cura.ContainerManager.setContainerMetaDataEntry(base.containerId, "adhesion_info", text)
  154. }
  155. }
  156. }
  157. }
  158. Tab
  159. {
  160. title: catalog.i18nc("@label", "Print settings")
  161. anchors
  162. {
  163. leftMargin: UM.Theme.getSize("default_margin").width
  164. topMargin: UM.Theme.getSize("default_margin").height
  165. bottomMargin: UM.Theme.getSize("default_margin").height
  166. rightMargin: 0
  167. }
  168. ScrollView
  169. {
  170. anchors.fill: parent;
  171. ListView
  172. {
  173. model: UM.SettingDefinitionsModel
  174. {
  175. containerId: Cura.MachineManager.activeDefinitionId
  176. visibilityHandler: Cura.MaterialSettingsVisibilityHandler { }
  177. expanded: ["*"]
  178. }
  179. delegate: UM.TooltipArea
  180. {
  181. width: childrenRect.width
  182. height: childrenRect.height
  183. text: model.description
  184. Label
  185. {
  186. id: label
  187. width: base.firstColumnWidth;
  188. height: spinBox.height
  189. text: model.label
  190. }
  191. ReadOnlySpinBox
  192. {
  193. id: spinBox
  194. anchors.left: label.right
  195. value: parseFloat(provider.properties.value);
  196. width: base.secondColumnWidth;
  197. readOnly: !base.editingEnabled
  198. suffix: model.unit
  199. maximumValue: 99999
  200. decimals: model.unit == "mm" ? 2 : 0
  201. onEditingFinished: provider.setPropertyValue("value", value)
  202. }
  203. UM.ContainerPropertyProvider { id: provider; containerId: base.containerId; watchedProperties: [ "value" ]; key: model.key }
  204. }
  205. }
  206. }
  207. }
  208. }