ReadOnlyTextArea.qml 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 2.15
  5. import UM 1.5 as UM
  6. ScrollView
  7. {
  8. id: base
  9. property alias text: textArea.text
  10. property alias wrapMode: textArea.wrapMode
  11. signal editingFinished();
  12. property bool readOnly: false
  13. TextArea
  14. {
  15. id: textArea
  16. enabled: !base.readOnly
  17. selectByMouse: true
  18. background: Rectangle
  19. {
  20. radius: UM.Theme.getSize("setting_control_radius").width
  21. color: textArea.enabled ? UM.Theme.getColor("setting_control") : UM.Theme.getColor("setting_control_disabled")
  22. }
  23. color: UM.Theme.getColor("text")
  24. font: UM.Theme.getFont("default")
  25. Keys.onReturnPressed: base.editingFinished()
  26. Keys.onEnterPressed: base.editingFinished()
  27. onActiveFocusChanged:
  28. {
  29. if(!activeFocus)
  30. {
  31. base.editingFinished()
  32. }
  33. }
  34. }
  35. }