ReadOnlySpinBox.qml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 1.1
  5. import QtQuick.Dialogs 1.2
  6. Item
  7. {
  8. id: base
  9. property alias value: spinBox.value
  10. property alias minimumValue: spinBox.minimumValue
  11. property alias maximumValue: spinBox.maximumValue
  12. property alias stepSize: spinBox.stepSize
  13. property alias prefix: spinBox.prefix
  14. property alias suffix: spinBox.suffix
  15. property alias decimals: spinBox.decimals
  16. signal editingFinished();
  17. property bool readOnly: false
  18. width: spinBox.width
  19. height: spinBox.height
  20. SpinBox
  21. {
  22. id: spinBox
  23. enabled: !base.readOnly
  24. opacity: base.readOnly ? 0.5 : 1.0
  25. anchors.fill: parent
  26. onEditingFinished: base.editingFinished()
  27. }
  28. Label
  29. {
  30. visible: base.readOnly
  31. text: base.prefix + base.value.toFixed(spinBox.decimals) + base.suffix
  32. anchors.verticalCenter: parent.verticalCenter
  33. anchors.left: parent.left
  34. anchors.leftMargin: spinBox.__style ? spinBox.__style.padding.left : 0
  35. color: palette.buttonText
  36. }
  37. SystemPalette { id: palette }
  38. }