ToolboxProgressButton.qml 1.7 KB

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