ToolboxInstalledTile.qml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. Item
  8. {
  9. height: UM.Theme.getSize("toolbox_installed_tile").height
  10. width: parent.width
  11. property bool canUpdate: false
  12. property bool isEnabled: true
  13. Rectangle
  14. {
  15. color: UM.Theme.getColor("lining")
  16. width: parent.width
  17. height: UM.Theme.getSize("default_lining").height
  18. anchors.bottom: parent.bottom
  19. }
  20. Row
  21. {
  22. id: tileRow
  23. height: parent.height
  24. width: parent.width
  25. spacing: UM.Theme.getSize("default_margin").width
  26. topPadding: UM.Theme.getSize("default_margin").height
  27. CheckBox
  28. {
  29. id: disableButton
  30. checked: isEnabled
  31. visible: model.type == "plugin"
  32. width: visible ? UM.Theme.getSize("checkbox").width : 0
  33. enabled: !toolbox.isDownloading
  34. style: UM.Theme.styles.checkbox
  35. onClicked: toolbox.isEnabled(model.id) ? toolbox.disable(model.id) : toolbox.enable(model.id)
  36. }
  37. Column
  38. {
  39. id: pluginInfo
  40. topPadding: UM.Theme.getSize("default_margin").height / 2
  41. property var color: model.type === "plugin" && !isEnabled ? UM.Theme.getColor("lining") : UM.Theme.getColor("text")
  42. width: tileRow.width - (authorInfo.width + pluginActions.width + 2 * tileRow.spacing + ((disableButton.visible) ? disableButton.width + tileRow.spacing : 0))
  43. Label
  44. {
  45. text: model.name
  46. width: parent.width
  47. height: UM.Theme.getSize("toolbox_property_label").height
  48. wrapMode: Text.WordWrap
  49. font: UM.Theme.getFont("default_bold")
  50. color: pluginInfo.color
  51. }
  52. Label
  53. {
  54. text: model.description
  55. maximumLineCount: 3
  56. elide: Text.ElideRight
  57. width: parent.width
  58. wrapMode: Text.WordWrap
  59. color: pluginInfo.color
  60. }
  61. }
  62. Column
  63. {
  64. id: authorInfo
  65. width: Math.floor(UM.Theme.getSize("toolbox_action_button").width * 1.25)
  66. Label
  67. {
  68. text:
  69. {
  70. if (model.author_email)
  71. {
  72. return "<a href=\"mailto:" + model.author_email + "?Subject=Cura: " + model.name + "\">" + model.author_name + "</a>"
  73. }
  74. else
  75. {
  76. return model.author_name
  77. }
  78. }
  79. width: parent.width
  80. height: UM.Theme.getSize("toolbox_property_label").height
  81. wrapMode: Text.WordWrap
  82. verticalAlignment: Text.AlignVCenter
  83. horizontalAlignment: Text.AlignLeft
  84. onLinkActivated: Qt.openUrlExternally("mailto:" + model.author_email + "?Subject=Cura: " + model.name + " Plugin")
  85. color: model.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
  86. linkColor: UM.Theme.getColor("text_link")
  87. }
  88. Label
  89. {
  90. text: model.version
  91. width: parent.width
  92. height: UM.Theme.getSize("toolbox_property_label").height
  93. color: UM.Theme.getColor("text")
  94. verticalAlignment: Text.AlignVCenter
  95. horizontalAlignment: Text.AlignLeft
  96. }
  97. }
  98. ToolboxInstalledTileActions
  99. {
  100. id: pluginActions
  101. }
  102. Connections
  103. {
  104. target: toolbox
  105. onEnabledChanged: isEnabled = toolbox.isEnabled(model.id)
  106. onMetadataChanged: canUpdate = toolbox.canUpdate(model.id)
  107. }
  108. }
  109. }