ToolboxDetailPage.qml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.3
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.1 as UM
  7. Item
  8. {
  9. id: page
  10. property var details: base.selection || dummy_details
  11. anchors.fill: parent
  12. width: parent.width
  13. property var dummy_details: new Object({
  14. name: '',
  15. version: '',
  16. last_updated: '',
  17. author_email: '',
  18. author_name: '',
  19. website: '',
  20. icon_url: '',
  21. download_count: ''
  22. })
  23. ToolboxBackColumn
  24. {
  25. id: sidebar
  26. }
  27. Item
  28. {
  29. id: header
  30. anchors
  31. {
  32. left: sidebar.right
  33. right: parent.right
  34. rightMargin: UM.Theme.getSize("wide_margin").width
  35. }
  36. height: UM.Theme.getSize("toolbox_detail_header").height
  37. Image
  38. {
  39. id: thumbnail
  40. width: UM.Theme.getSize("toolbox_thumbnail_medium").width
  41. height: UM.Theme.getSize("toolbox_thumbnail_medium").height
  42. fillMode: Image.PreserveAspectFit
  43. source: details.icon_url || "../images/logobot.svg"
  44. mipmap: true
  45. anchors
  46. {
  47. top: parent.top
  48. left: parent.left
  49. leftMargin: UM.Theme.getSize("wide_margin").width
  50. topMargin: UM.Theme.getSize("wide_margin").height
  51. }
  52. }
  53. Label
  54. {
  55. id: title
  56. anchors
  57. {
  58. top: thumbnail.top
  59. left: thumbnail.right
  60. leftMargin: UM.Theme.getSize("default_margin").width
  61. right: parent.right
  62. rightMargin: UM.Theme.getSize("wide_margin").width
  63. bottomMargin: UM.Theme.getSize("default_margin").height
  64. }
  65. text: details.name || ""
  66. font: UM.Theme.getFont("large")
  67. color: UM.Theme.getColor("text")
  68. wrapMode: Text.WordWrap
  69. width: parent.width
  70. height: UM.Theme.getSize("toolbox_property_label").height
  71. }
  72. Column
  73. {
  74. id: properties
  75. anchors
  76. {
  77. top: title.bottom
  78. left: title.left
  79. topMargin: UM.Theme.getSize("default_margin").height
  80. }
  81. spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
  82. width: childrenRect.width
  83. Label
  84. {
  85. text: catalog.i18nc("@label", "Version") + ":"
  86. font: UM.Theme.getFont("very_small")
  87. color: UM.Theme.getColor("text_medium")
  88. }
  89. Label
  90. {
  91. text: catalog.i18nc("@label", "Last updated") + ":"
  92. font: UM.Theme.getFont("very_small")
  93. color: UM.Theme.getColor("text_medium")
  94. }
  95. Label
  96. {
  97. text: catalog.i18nc("@label", "Author") + ":"
  98. font: UM.Theme.getFont("very_small")
  99. color: UM.Theme.getColor("text_medium")
  100. }
  101. Label
  102. {
  103. text: catalog.i18nc("@label", "Downloads") + ":"
  104. font: UM.Theme.getFont("very_small")
  105. color: UM.Theme.getColor("text_medium")
  106. }
  107. }
  108. Column
  109. {
  110. id: values
  111. anchors
  112. {
  113. top: title.bottom
  114. left: properties.right
  115. leftMargin: UM.Theme.getSize("default_margin").width
  116. topMargin: UM.Theme.getSize("default_margin").height
  117. }
  118. spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
  119. Label
  120. {
  121. text: details.version || catalog.i18nc("@label", "Unknown")
  122. font: UM.Theme.getFont("very_small")
  123. color: UM.Theme.getColor("text")
  124. }
  125. Label
  126. {
  127. text:
  128. {
  129. var date = new Date(details.last_updated)
  130. return date.toLocaleString(UM.Preferences.getValue("general/language"))
  131. }
  132. font: UM.Theme.getFont("very_small")
  133. color: UM.Theme.getColor("text")
  134. }
  135. Label
  136. {
  137. text:
  138. {
  139. if (details.author_email)
  140. {
  141. return "<a href=\"mailto:" + details.author_email+"?Subject=Cura: " + details.name + "\">" + details.author_name + "</a>"
  142. }
  143. else
  144. {
  145. return "<a href=\"" + details.website + "\">" + details.author_name + "</a>"
  146. }
  147. }
  148. font: UM.Theme.getFont("very_small")
  149. color: UM.Theme.getColor("text")
  150. linkColor: UM.Theme.getColor("text_link")
  151. onLinkActivated: Qt.openUrlExternally(link)
  152. }
  153. Label
  154. {
  155. text: details.download_count || catalog.i18nc("@label", "Unknown")
  156. font: UM.Theme.getFont("very_small")
  157. color: UM.Theme.getColor("text")
  158. }
  159. }
  160. Rectangle
  161. {
  162. color: UM.Theme.getColor("lining")
  163. width: parent.width
  164. height: UM.Theme.getSize("default_lining").height
  165. anchors.bottom: parent.bottom
  166. }
  167. }
  168. ToolboxDetailList
  169. {
  170. anchors
  171. {
  172. top: header.bottom
  173. bottom: page.bottom
  174. left: header.left
  175. right: page.right
  176. }
  177. }
  178. }