ToolboxInstalledTileActions.qml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 canUpdate: false
  10. property bool canDowngrade: false
  11. width: UM.Theme.getSize("toolbox_action_button").width
  12. spacing: UM.Theme.getSize("narrow_margin").height
  13. Label
  14. {
  15. visible: !model.is_installed
  16. text: catalog.i18nc("@label", "Will install upon restarting")
  17. color: UM.Theme.getColor("lining")
  18. font: UM.Theme.getFont("default")
  19. wrapMode: Text.WordWrap
  20. width: parent.width
  21. }
  22. ToolboxProgressButton
  23. {
  24. id: updateButton
  25. active: toolbox.isDownloading && toolbox.activePackage == model
  26. readyLabel: catalog.i18nc("@action:button", "Update")
  27. activeLabel: catalog.i18nc("@action:button", "Updating")
  28. completeLabel: catalog.i18nc("@action:button", "Updated")
  29. readyAction: function()
  30. {
  31. toolbox.activePackage = model
  32. toolbox.update(model.id)
  33. }
  34. activeAction: function()
  35. {
  36. toolbox.cancelDownload()
  37. }
  38. // Don't allow installing while another download is running
  39. enabled: !(toolbox.isDownloading && toolbox.activePackage != model)
  40. opacity: enabled ? 1.0 : 0.5
  41. visible: canUpdate
  42. }
  43. Button
  44. {
  45. id: removeButton
  46. text: canDowngrade ? catalog.i18nc("@action:button", "Downgrade") : catalog.i18nc("@action:button", "Uninstall")
  47. visible: !model.is_bundled && model.is_installed
  48. enabled: !toolbox.isDownloading
  49. style: ButtonStyle
  50. {
  51. background: Rectangle
  52. {
  53. implicitWidth: UM.Theme.getSize("toolbox_action_button").width
  54. implicitHeight: UM.Theme.getSize("toolbox_action_button").height
  55. color: "transparent"
  56. border
  57. {
  58. width: UM.Theme.getSize("default_lining").width
  59. color:
  60. {
  61. if (control.hovered)
  62. {
  63. return UM.Theme.getColor("primary_hover")
  64. }
  65. else
  66. {
  67. return UM.Theme.getColor("lining")
  68. }
  69. }
  70. }
  71. }
  72. label: Label
  73. {
  74. text: control.text
  75. color: UM.Theme.getColor("text")
  76. verticalAlignment: Text.AlignVCenter
  77. horizontalAlignment: Text.AlignHCenter
  78. font: UM.Theme.getFont("default")
  79. }
  80. }
  81. onClicked: toolbox.uninstall(model.id)
  82. Connections
  83. {
  84. target: toolbox
  85. onMetadataChanged:
  86. {
  87. canUpdate = toolbox.canUpdate(model.id)
  88. canDowngrade = toolbox.canDowngrade(model.id)
  89. }
  90. }
  91. }
  92. }