ReadOnlyTextField.qml 892 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: textField.text
  10. signal editingFinished();
  11. property bool readOnly: false
  12. width: textField.width
  13. height: textField.height
  14. TextField
  15. {
  16. id: textField
  17. enabled: !base.readOnly
  18. opacity: base.readOnly ? 0.5 : 1.0
  19. anchors.fill: parent
  20. onEditingFinished: base.editingFinished()
  21. }
  22. Label
  23. {
  24. visible: base.readOnly
  25. text: textField.text
  26. anchors.verticalCenter: parent.verticalCenter
  27. anchors.left: parent.left
  28. anchors.leftMargin: textField.__panel ? textField.__panel.leftMargin : 0
  29. color: palette.buttonText
  30. }
  31. SystemPalette { id: palette }
  32. }