GcodeTextArea.qml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright (c) 2019 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
  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. TextArea
  44. {
  45. id: gcodeTextArea
  46. hoverEnabled: true
  47. selectByMouse: true
  48. text: (propertyProvider.properties.value) ? propertyProvider.properties.value : ""
  49. font: UM.Theme.getFont("fixed")
  50. renderType: Text.NativeRendering
  51. color: UM.Theme.getColor("text")
  52. wrapMode: TextEdit.NoWrap
  53. background: Rectangle
  54. {
  55. color: UM.Theme.getColor("main_background")
  56. anchors.fill: parent
  57. border.color:
  58. {
  59. if (!gcodeTextArea.enabled)
  60. {
  61. return UM.Theme.getColor("setting_control_disabled_border")
  62. }
  63. if (gcodeTextArea.hovered || gcodeTextArea.activeFocus)
  64. {
  65. return UM.Theme.getColor("setting_control_border_highlight")
  66. }
  67. return UM.Theme.getColor("setting_control_border")
  68. }
  69. }
  70. onActiveFocusChanged:
  71. {
  72. if (!activeFocus)
  73. {
  74. propertyProvider.setPropertyValue("value", text)
  75. }
  76. }
  77. }
  78. }
  79. }