ToolboxInstalledTile.qml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.1 as UM
  7. Item
  8. {
  9. property bool canUpdate: false
  10. property bool isEnabled: true
  11. height: UM.Theme.getSize("toolbox_installed_tile").height
  12. anchors
  13. {
  14. left: parent.left
  15. right: parent.right
  16. }
  17. Rectangle
  18. {
  19. color: UM.Theme.getColor("lining")
  20. width: parent.width
  21. height: UM.Theme.getSize("default_lining").height
  22. anchors.bottom: parent.bottom
  23. }
  24. Column
  25. {
  26. id: pluginInfo
  27. property var color: isEnabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
  28. height: parent.height
  29. anchors
  30. {
  31. left: parent.left
  32. top: parent.top
  33. right: authorInfo.left
  34. topMargin: UM.Theme.getSize("default_margin").height
  35. rightMargin: UM.Theme.getSize("default_margin").width
  36. }
  37. Label
  38. {
  39. text: model.name
  40. width: parent.width
  41. height: UM.Theme.getSize("toolbox_property_label").height
  42. wrapMode: Text.WordWrap
  43. verticalAlignment: Text.AlignVCenter
  44. font: UM.Theme.getFont("default_bold")
  45. color: pluginInfo.color
  46. }
  47. Text
  48. {
  49. text: model.description
  50. width: parent.width
  51. height: UM.Theme.getSize("toolbox_property_label").height
  52. clip: true
  53. wrapMode: Text.WordWrap
  54. color: pluginInfo.color
  55. elide: Text.ElideRight
  56. }
  57. }
  58. Column
  59. {
  60. id: authorInfo
  61. height: parent.height
  62. width: Math.floor(UM.Theme.getSize("toolbox_action_button").width * 1.25)
  63. anchors
  64. {
  65. top: parent.top
  66. topMargin: UM.Theme.getSize("default_margin").height
  67. right: pluginActions.left
  68. rightMargin: UM.Theme.getSize("default_margin").width
  69. }
  70. Label
  71. {
  72. text:
  73. {
  74. if (model.author_email)
  75. {
  76. return "<a href=\"mailto:" + model.author_email + "?Subject=Cura: " + model.name + "\">" + model.author_name + "</a>"
  77. }
  78. else
  79. {
  80. return model.author_name
  81. }
  82. }
  83. width: parent.width
  84. height: 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. }
  91. }
  92. Column
  93. {
  94. id: pluginActions
  95. width: childrenRect.width
  96. height: childrenRect.height
  97. spacing: UM.Theme.getSize("default_margin").height
  98. anchors
  99. {
  100. top: parent.top
  101. right: parent.right
  102. topMargin: UM.Theme.getSize("default_margin").height
  103. }
  104. Button {
  105. id: removeButton
  106. text:
  107. {
  108. if (model.is_bundled)
  109. {
  110. return isEnabled ? catalog.i18nc("@action:button", "Disable") : catalog.i18nc("@action:button", "Enable")
  111. }
  112. else
  113. {
  114. return catalog.i18nc("@action:button", "Uninstall")
  115. }
  116. }
  117. enabled: !toolbox.isDownloading
  118. style: ButtonStyle
  119. {
  120. background: Rectangle
  121. {
  122. implicitWidth: UM.Theme.getSize("toolbox_action_button").width
  123. implicitHeight: UM.Theme.getSize("toolbox_action_button").height
  124. color: "transparent"
  125. border
  126. {
  127. width: UM.Theme.getSize("default_lining").width
  128. color: UM.Theme.getColor("lining")
  129. }
  130. }
  131. label: Text
  132. {
  133. text: control.text
  134. color: UM.Theme.getColor("text")
  135. verticalAlignment: Text.AlignVCenter
  136. horizontalAlignment: Text.AlignHCenter
  137. }
  138. }
  139. onClicked:
  140. {
  141. if (model.is_bundled)
  142. {
  143. if (toolbox.isEnabled(model.id))
  144. {
  145. toolbox.disable(model.id)
  146. }
  147. else
  148. {
  149. toolbox.enable(model.id)
  150. }
  151. }
  152. else
  153. {
  154. toolbox.uninstall( model.id )
  155. }
  156. }
  157. }
  158. Button
  159. {
  160. id: updateButton
  161. text: catalog.i18nc("@action:button", "Update")
  162. visible: canUpdate
  163. style: ButtonStyle
  164. {
  165. background: Rectangle
  166. {
  167. implicitWidth: UM.Theme.getSize("toolbox_action_button").width
  168. implicitHeight: UM.Theme.getSize("toolbox_action_button").height
  169. color: control.hovered ? UM.Theme.getColor("primary_hover") : UM.Theme.getColor("primary")
  170. }
  171. label: Label
  172. {
  173. text: control.text
  174. color: control.hovered ? UM.Theme.getColor("button_text") : UM.Theme.getColor("button_text_hover")
  175. verticalAlignment: Text.AlignVCenter
  176. horizontalAlignment: Text.AlignHCenter
  177. font: UM.Theme.getFont("default_bold")
  178. }
  179. }
  180. onClicked:
  181. {
  182. toolbox.update(model.id);
  183. }
  184. }
  185. ProgressBar
  186. {
  187. id: progressbar
  188. anchors
  189. {
  190. left: updateButton.left
  191. right: updateButton.right
  192. top: updateButton.bottom
  193. topMargin: Math.floor(UM.Theme.getSize("default_margin") / 4)
  194. }
  195. value: toolbox.isDownloading ? toolbox.downloadProgress : 0
  196. visible: toolbox.isDownloading
  197. style: ProgressBarStyle
  198. {
  199. background: Rectangle
  200. {
  201. color: UM.Theme.getColor("lining")
  202. implicitHeight: Math.floor(UM.Theme.getSize("toolbox_progress_bar").height)
  203. }
  204. progress: Rectangle
  205. {
  206. color: UM.Theme.getColor("primary")
  207. }
  208. }
  209. }
  210. }
  211. Connections
  212. {
  213. target: toolbox
  214. onEnabledChanged: isEnabled = toolbox.isEnabled(model.id)
  215. onMetadataChanged: canUpdate = toolbox.canUpdate(model.id)
  216. }
  217. }