ToolboxInstalledTile.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.top
  18. visible: index != 0
  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. anchors.verticalCenter: pluginInfo.verticalCenter
  31. checked: isEnabled
  32. visible: model.type == "plugin"
  33. width: visible ? UM.Theme.getSize("checkbox").width : 0
  34. enabled: !toolbox.isDownloading
  35. style: UM.Theme.styles.checkbox
  36. onClicked: toolbox.isEnabled(model.id) ? toolbox.disable(model.id) : toolbox.enable(model.id)
  37. }
  38. Column
  39. {
  40. id: pluginInfo
  41. topPadding: UM.Theme.getSize("narrow_margin").height
  42. property var color: model.type === "plugin" && !isEnabled ? UM.Theme.getColor("lining") : UM.Theme.getColor("text")
  43. width: Math.floor(tileRow.width - (authorInfo.width + pluginActions.width + 2 * tileRow.spacing + ((disableButton.visible) ? disableButton.width + tileRow.spacing : 0)))
  44. Label
  45. {
  46. text: model.name
  47. width: parent.width
  48. maximumLineCount: 1
  49. elide: Text.ElideRight
  50. wrapMode: Text.WordWrap
  51. font: UM.Theme.getFont("large_bold")
  52. color: pluginInfo.color
  53. renderType: Text.NativeRendering
  54. }
  55. Label
  56. {
  57. text: model.description
  58. font: UM.Theme.getFont("default")
  59. maximumLineCount: 3
  60. elide: Text.ElideRight
  61. width: parent.width
  62. wrapMode: Text.WordWrap
  63. color: pluginInfo.color
  64. renderType: Text.NativeRendering
  65. }
  66. }
  67. Column
  68. {
  69. id: authorInfo
  70. width: Math.floor(UM.Theme.getSize("toolbox_action_button").width * 1.25)
  71. Label
  72. {
  73. text:
  74. {
  75. if (model.author_email)
  76. {
  77. return "<a href=\"mailto:" + model.author_email + "?Subject=Cura: " + model.name + "\">" + model.author_name + "</a>"
  78. }
  79. else
  80. {
  81. return model.author_name
  82. }
  83. }
  84. font: UM.Theme.getFont("medium")
  85. width: parent.width
  86. height: Math.floor(UM.Theme.getSize("toolbox_property_label").height)
  87. wrapMode: Text.WordWrap
  88. verticalAlignment: Text.AlignVCenter
  89. horizontalAlignment: Text.AlignLeft
  90. onLinkActivated: Qt.openUrlExternally("mailto:" + model.author_email + "?Subject=Cura: " + model.name + " Plugin")
  91. color: model.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
  92. linkColor: UM.Theme.getColor("text_link")
  93. renderType: Text.NativeRendering
  94. }
  95. Label
  96. {
  97. text: model.version
  98. font: UM.Theme.getFont("default")
  99. width: parent.width
  100. height: UM.Theme.getSize("toolbox_property_label").height
  101. color: UM.Theme.getColor("text")
  102. verticalAlignment: Text.AlignVCenter
  103. horizontalAlignment: Text.AlignLeft
  104. renderType: Text.NativeRendering
  105. }
  106. }
  107. ToolboxInstalledTileActions
  108. {
  109. id: pluginActions
  110. }
  111. Connections
  112. {
  113. target: toolbox
  114. function onToolboxEnabledChanged() { isEnabled = toolbox.isEnabled(model.id) }
  115. }
  116. }
  117. }