GcodeTextArea.qml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright (c) 2020 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import QtQuick.Layouts 1.3
  6. import UM 1.3 as UM
  7. import Cura 1.1 as Cura
  8. //
  9. // TextArea widget for editing Gcode in the Machine Settings dialog.
  10. //
  11. UM.TooltipArea
  12. {
  13. id: control
  14. UM.I18nCatalog { id: catalog; name: "cura"; }
  15. text: tooltip
  16. property alias containerStackId: propertyProvider.containerStackId
  17. property alias settingKey: propertyProvider.key
  18. property alias settingStoreIndex: propertyProvider.storeIndex
  19. property string tooltip: propertyProvider.properties.description ? propertyProvider.properties.description : ""
  20. property alias labelText: titleLabel.text
  21. property alias labelFont: titleLabel.font
  22. UM.SettingPropertyProvider
  23. {
  24. id: propertyProvider
  25. watchedProperties: [ "value", "description" ]
  26. }
  27. Label // Title Label
  28. {
  29. id: titleLabel
  30. anchors.top: parent.top
  31. anchors.left: parent.left
  32. font: UM.Theme.getFont("medium_bold")
  33. color: UM.Theme.getColor("text")
  34. renderType: Text.NativeRendering
  35. }
  36. ScrollView
  37. {
  38. anchors.top: titleLabel.bottom
  39. anchors.topMargin: UM.Theme.getSize("default_margin").height
  40. anchors.bottom: parent.bottom
  41. anchors.left: parent.left
  42. anchors.right: parent.right
  43. background: Rectangle
  44. {
  45. color: UM.Theme.getColor("main_background")
  46. anchors.fill: parent
  47. border.color:
  48. {
  49. if (!gcodeTextArea.enabled)
  50. {
  51. return UM.Theme.getColor("setting_control_disabled_border")
  52. }
  53. if (gcodeTextArea.hovered || gcodeTextArea.activeFocus)
  54. {
  55. return UM.Theme.getColor("setting_control_border_highlight")
  56. }
  57. return UM.Theme.getColor("setting_control_border")
  58. }
  59. }
  60. TextArea
  61. {
  62. id: gcodeTextArea
  63. hoverEnabled: true
  64. selectByMouse: true
  65. text: (propertyProvider.properties.value) ? propertyProvider.properties.value : ""
  66. font: UM.Theme.getFont("fixed")
  67. renderType: Text.NativeRendering
  68. color: UM.Theme.getColor("text")
  69. wrapMode: TextEdit.NoWrap
  70. onActiveFocusChanged:
  71. {
  72. if (!activeFocus)
  73. {
  74. propertyProvider.setPropertyValue("value", text)
  75. }
  76. }
  77. }
  78. }
  79. }