ToolboxInstalledTile.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. 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. anchors.verticalCenter: pluginInfo.verticalCenter
  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: Math.floor(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: Math.floor(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: Math.floor(UM.Theme.getSize("toolbox_property_label").height)
  48. wrapMode: Text.WordWrap
  49. font: UM.Theme.getFont("large_bold")
  50. color: pluginInfo.color
  51. renderType: Text.NativeRendering
  52. }
  53. Label
  54. {
  55. text: model.description
  56. font: UM.Theme.getFont("default")
  57. maximumLineCount: 3
  58. elide: Text.ElideRight
  59. width: parent.width
  60. wrapMode: Text.WordWrap
  61. color: pluginInfo.color
  62. renderType: Text.NativeRendering
  63. }
  64. }
  65. Column
  66. {
  67. id: authorInfo
  68. width: Math.floor(UM.Theme.getSize("toolbox_action_button").width * 1.25)
  69. Label
  70. {
  71. text:
  72. {
  73. if (model.author_email)
  74. {
  75. return "<a href=\"mailto:" + model.author_email + "?Subject=Cura: " + model.name + "\">" + model.author_name + "</a>"
  76. }
  77. else
  78. {
  79. return model.author_name
  80. }
  81. }
  82. font: UM.Theme.getFont("medium")
  83. width: parent.width
  84. height: Math.floor(UM.Theme.getSize("toolbox_property_label").height)
  85. wrapMode: Text.WordWrap
  86. verticalAlignment: Text.AlignVCenter
  87. horizontalAlignment: Text.AlignLeft
  88. onLinkActivated: Qt.openUrlExternally("mailto:" + model.author_email + "?Subject=Cura: " + model.name + " Plugin")
  89. color: model.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
  90. linkColor: UM.Theme.getColor("text_link")
  91. renderType: Text.NativeRendering
  92. }
  93. Label
  94. {
  95. text: model.version
  96. font: UM.Theme.getFont("default")
  97. width: parent.width
  98. height: UM.Theme.getSize("toolbox_property_label").height
  99. color: UM.Theme.getColor("text")
  100. verticalAlignment: Text.AlignVCenter
  101. horizontalAlignment: Text.AlignLeft
  102. renderType: Text.NativeRendering
  103. }
  104. }
  105. ToolboxInstalledTileActions
  106. {
  107. id: pluginActions
  108. }
  109. Connections
  110. {
  111. target: toolbox
  112. onEnabledChanged: isEnabled = toolbox.isEnabled(model.id)
  113. }
  114. }
  115. }