ReadOnlyTextArea.qml 869 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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.1
  5. import QtQuick.Dialogs 1.2
  6. Item
  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. width: textArea.width
  14. height: textArea.height
  15. TextArea
  16. {
  17. id: textArea
  18. enabled: !base.readOnly
  19. opacity: base.readOnly ? 0.5 : 1.0
  20. anchors.fill: parent
  21. onEditingFinished: base.editingFinished()
  22. }
  23. Label
  24. {
  25. visible: base.readOnly
  26. text: textArea.text
  27. anchors.fill: parent
  28. anchors.margins: textArea.__style ? textArea.__style.textMargin : 4
  29. color: palette.buttonText
  30. }
  31. SystemPalette { id: palette }
  32. }