ToolboxDetailTileActions.qml 2.1 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.7
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.1 as UM
  7. Column
  8. {
  9. property bool installed: toolbox.isInstalled(model.id)
  10. property bool canUpdate: toolbox.canUpdate(model.id)
  11. width: UM.Theme.getSize("toolbox_action_button").width
  12. spacing: UM.Theme.getSize("narrow_margin").height
  13. ToolboxProgressButton
  14. {
  15. id: installButton
  16. active: toolbox.isDownloading && toolbox.activePackage == model
  17. complete: installed
  18. readyAction: function()
  19. {
  20. toolbox.activePackage = model
  21. toolbox.startDownload(model.download_url)
  22. }
  23. activeAction: function()
  24. {
  25. toolbox.cancelDownload()
  26. }
  27. completeAction: function()
  28. {
  29. toolbox.viewCategory = "installed"
  30. }
  31. // Don't allow installing while another download is running
  32. enabled: installed || !(toolbox.isDownloading && toolbox.activePackage != model)
  33. opacity: enabled ? 1.0 : 0.5
  34. visible: !updateButton.visible // Don't show when the update button is visible
  35. }
  36. ToolboxProgressButton
  37. {
  38. id: updateButton
  39. active: toolbox.isDownloading && toolbox.activePackage == model
  40. readyLabel: catalog.i18nc("@action:button", "Update")
  41. activeLabel: catalog.i18nc("@action:button", "Updating")
  42. completeLabel: catalog.i18nc("@action:button", "Updated")
  43. readyAction: function()
  44. {
  45. toolbox.activePackage = model
  46. toolbox.update(model.id)
  47. }
  48. activeAction: function()
  49. {
  50. toolbox.cancelDownload()
  51. }
  52. // Don't allow installing while another download is running
  53. enabled: !(toolbox.isDownloading && toolbox.activePackage != model)
  54. opacity: enabled ? 1.0 : 0.5
  55. visible: canUpdate
  56. }
  57. Connections
  58. {
  59. target: toolbox
  60. onInstallChanged: installed = toolbox.isInstalled(model.id)
  61. onMetadataChanged: canUpdate = toolbox.canUpdate(model.id)
  62. }
  63. }