ToolboxProgressButton.qml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.1 as UM
  6. import Cura 1.0 as Cura
  7. Cura.PrimaryButton
  8. {
  9. id: button
  10. property var active: false
  11. property var complete: false
  12. property var readyLabel: catalog.i18nc("@action:button", "Install")
  13. property var activeLabel: catalog.i18nc("@action:button", "Cancel")
  14. property var completeLabel: catalog.i18nc("@action:button", "Installed")
  15. signal readyAction() // Action when button is ready and clicked (likely install)
  16. signal activeAction() // Action when button is active and clicked (likely cancel)
  17. signal completeAction() // Action when button is complete and clicked (likely go to installed)
  18. width: UM.Theme.getSize("toolbox_action_button").width
  19. height: UM.Theme.getSize("toolbox_action_button").height
  20. fixedWidthMode: true
  21. text:
  22. {
  23. if (complete)
  24. {
  25. return completeLabel
  26. }
  27. else if (active)
  28. {
  29. return activeLabel
  30. }
  31. else
  32. {
  33. return readyLabel
  34. }
  35. }
  36. onClicked:
  37. {
  38. if (complete)
  39. {
  40. completeAction()
  41. }
  42. else if (active)
  43. {
  44. activeAction()
  45. }
  46. else
  47. {
  48. readyAction()
  49. }
  50. }
  51. busy: active
  52. }