ToolboxInstalledTile.qml 3.9 KB

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