ToolboxInstalledTileActions.qml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.1 as UM
  7. import Cura 1.1 as Cura
  8. Column
  9. {
  10. property bool canUpdate: CuraApplication.getPackageManager().packagesWithUpdate.indexOf(model.id) != -1
  11. property bool canDowngrade: false
  12. property bool loginRequired: model.login_required && !Cura.API.account.isLoggedIn
  13. width: UM.Theme.getSize("toolbox_action_button").width
  14. spacing: UM.Theme.getSize("narrow_margin").height
  15. Label
  16. {
  17. visible: !model.is_installed
  18. text: catalog.i18nc("@label", "Will install upon restarting")
  19. color: UM.Theme.getColor("lining")
  20. font: UM.Theme.getFont("default")
  21. wrapMode: Text.WordWrap
  22. width: parent.width
  23. renderType: Text.NativeRendering
  24. }
  25. ToolboxProgressButton
  26. {
  27. id: updateButton
  28. active: toolbox.isDownloading && toolbox.activePackage == model
  29. readyLabel: catalog.i18nc("@action:button", "Update")
  30. activeLabel: catalog.i18nc("@action:button", "Updating")
  31. completeLabel: catalog.i18nc("@action:button", "Updated")
  32. onReadyAction:
  33. {
  34. toolbox.activePackage = model
  35. toolbox.update(model.id)
  36. }
  37. onActiveAction: toolbox.cancelDownload()
  38. // Don't allow installing while another download is running
  39. enabled: !(toolbox.isDownloading && toolbox.activePackage != model) && !loginRequired
  40. opacity: enabled ? 1.0 : 0.5
  41. visible: canUpdate
  42. }
  43. Label
  44. {
  45. wrapMode: Text.WordWrap
  46. text: catalog.i18nc("@label:The string between <a href=> and </a> is the highlighted link", "<a href='%1'>Log in</a> is required to update")
  47. font: UM.Theme.getFont("default")
  48. color: UM.Theme.getColor("text")
  49. linkColor: UM.Theme.getColor("text_link")
  50. visible: loginRequired
  51. width: updateButton.width
  52. renderType: Text.NativeRendering
  53. MouseArea
  54. {
  55. anchors.fill: parent
  56. onClicked: Cura.API.account.login()
  57. }
  58. }
  59. Cura.SecondaryButton
  60. {
  61. id: removeButton
  62. text: canDowngrade ? catalog.i18nc("@action:button", "Downgrade") : catalog.i18nc("@action:button", "Uninstall")
  63. visible: !model.is_bundled && model.is_installed
  64. enabled: !toolbox.isDownloading
  65. width: UM.Theme.getSize("toolbox_action_button").width
  66. height: UM.Theme.getSize("toolbox_action_button").height
  67. fixedWidthMode: true
  68. onClicked: toolbox.checkPackageUsageAndUninstall(model.id)
  69. Connections
  70. {
  71. target: toolbox
  72. onMetadataChanged:
  73. {
  74. canDowngrade = toolbox.canDowngrade(model.id)
  75. }
  76. }
  77. }
  78. }