MaterialView.qml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. TextField { id: textField; width: base.secondColumnWidth; text: properties.supplier; readOnly: !base.editingEnabled; }
  38. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") }
  39. TextField { width: base.secondColumnWidth; text: properties.material_type; readOnly: !base.editingEnabled; }
  40. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") }
  41. Row
  42. {
  43. width: base.secondColumnWidth;
  44. height: parent.rowHeight;
  45. spacing: UM.Theme.getSize("default_margin").width/2
  46. Rectangle
  47. {
  48. id: colorSelector
  49. color: properties.color_code
  50. width: colorLabel.height * 0.75
  51. height: colorLabel.height * 0.75
  52. border.width: UM.Theme.getSize("default_lining").height
  53. anchors.verticalCenter: parent.verticalCenter
  54. MouseArea { anchors.fill: parent; onClicked: colorDialog.open(); enabled: base.editingEnabled }
  55. }
  56. TextField { id: colorLabel; text: properties.color_name; readOnly: !base.editingEnabled }
  57. ColorDialog { id: colorDialog; color: properties.color_code; onAccepted: colorSelector.color = color }
  58. }
  59. Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
  60. Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: "<b>" + catalog.i18nc("@label", "Properties") + "</b>" }
  61. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") }
  62. ReadOnlySpinBox
  63. {
  64. width: base.secondColumnWidth;
  65. value: properties.density;
  66. decimals: 2
  67. suffix: "g/cm"
  68. stepSize: 0.01
  69. readOnly: !base.editingEnabled;
  70. }
  71. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") }
  72. ReadOnlySpinBox
  73. {
  74. width: base.secondColumnWidth;
  75. value: properties.diameter;
  76. decimals: 2
  77. suffix: "mm³"
  78. stepSize: 0.01
  79. readOnly: !base.editingEnabled;
  80. }
  81. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") }
  82. ReadOnlySpinBox
  83. {
  84. width: base.secondColumnWidth;
  85. value: properties.spool_cost;
  86. prefix: base.currency
  87. readOnly: !base.editingEnabled;
  88. }
  89. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") }
  90. ReadOnlySpinBox
  91. {
  92. width: base.secondColumnWidth;
  93. value: properties.spool_weight;
  94. suffix: "g";
  95. stepSize: 10
  96. readOnly: !base.editingEnabled;
  97. }
  98. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") }
  99. ReadOnlySpinBox
  100. {
  101. width: base.secondColumnWidth;
  102. value: parseFloat(properties.spool_length);
  103. suffix: "m";
  104. readOnly: !base.editingEnabled;
  105. }
  106. Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter (Approx.)") }
  107. ReadOnlySpinBox
  108. {
  109. width: base.secondColumnWidth;
  110. value: parseFloat(properties.cost_per_meter);
  111. suffix: catalog.i18nc("@label", "%1/m".arg(base.currency));
  112. readOnly: !base.editingEnabled;
  113. }
  114. Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
  115. Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Description") }
  116. TextArea
  117. {
  118. text: properties.description;
  119. width: base.firstColumnWidth + base.secondColumnWidth
  120. wrapMode: Text.WordWrap
  121. readOnly: !base.editingEnabled;
  122. }
  123. Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Adhesion Information") }
  124. TextArea
  125. {
  126. text: properties.adhesion_info;
  127. width: base.firstColumnWidth + base.secondColumnWidth
  128. wrapMode: Text.WordWrap
  129. readOnly: !base.editingEnabled;
  130. }
  131. }
  132. }
  133. }
  134. Tab
  135. {
  136. title: catalog.i18nc("@label", "Print settings")
  137. anchors
  138. {
  139. leftMargin: UM.Theme.getSize("default_margin").width
  140. topMargin: UM.Theme.getSize("default_margin").height
  141. bottomMargin: UM.Theme.getSize("default_margin").height
  142. rightMargin: 0
  143. }
  144. ScrollView
  145. {
  146. anchors.fill: parent;
  147. ListView
  148. {
  149. model: UM.SettingDefinitionsModel
  150. {
  151. containerId: Cura.MachineManager.activeDefinitionId
  152. visibilityHandler: Cura.MaterialSettingsVisibilityHandler { }
  153. expanded: ["*"]
  154. }
  155. delegate: UM.TooltipArea
  156. {
  157. width: childrenRect.width
  158. height: childrenRect.height
  159. text: model.description
  160. Label
  161. {
  162. id: label
  163. width: base.firstColumnWidth;
  164. height: spinBox.height
  165. text: model.label
  166. }
  167. ReadOnlySpinBox
  168. {
  169. id: spinBox
  170. anchors.left: label.right
  171. value: parseFloat(provider.properties.value);
  172. width: base.secondColumnWidth;
  173. readOnly: !base.editingEnabled
  174. suffix: model.unit
  175. maximumValue: 99999
  176. decimals: model.unit == "mm" ? 2 : 0
  177. onEditingFinished: provider.setPropertyValue("value", value)
  178. }
  179. UM.ContainerPropertyProvider { id: provider; containerId: base.containerId; watchedProperties: [ "value" ]; key: model.key }
  180. }
  181. }
  182. }
  183. }
  184. }