ReadOnlyTextField.qml 954 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. // Different than the name suggests, it is not always read-only.
  4. import QtQuick 2.1
  5. import QtQuick.Controls 1.1
  6. import QtQuick.Dialogs 1.2
  7. Item
  8. {
  9. id: base
  10. property alias text: textField.text
  11. signal editingFinished();
  12. property bool readOnly: false
  13. width: textField.width
  14. height: textField.height
  15. TextField
  16. {
  17. id: textField
  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: textField.text
  27. anchors.verticalCenter: parent.verticalCenter
  28. anchors.left: parent.left
  29. anchors.leftMargin: textField.__panel ? textField.__panel.leftMargin : 0
  30. color: palette.buttonText
  31. }
  32. SystemPalette { id: palette }
  33. }