ToolboxDetailPage.qml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.5 as UM
  7. import Cura 1.1 as Cura
  8. import "../components"
  9. Item
  10. {
  11. id: page
  12. property var details: base.selection || {}
  13. anchors.fill: parent
  14. ToolboxBackColumn
  15. {
  16. id: sidebar
  17. }
  18. Item
  19. {
  20. id: header
  21. anchors
  22. {
  23. left: sidebar.right
  24. right: parent.right
  25. rightMargin: UM.Theme.getSize("wide_margin").width
  26. }
  27. height: childrenRect.height + 3 * UM.Theme.getSize("default_margin").width
  28. Rectangle
  29. {
  30. id: thumbnail
  31. width: UM.Theme.getSize("toolbox_thumbnail_medium").width
  32. height: UM.Theme.getSize("toolbox_thumbnail_medium").height
  33. anchors
  34. {
  35. top: parent.top
  36. left: parent.left
  37. leftMargin: UM.Theme.getSize("wide_margin").width
  38. topMargin: UM.Theme.getSize("wide_margin").height
  39. }
  40. color: UM.Theme.getColor("main_background")
  41. Image
  42. {
  43. anchors.fill: parent
  44. fillMode: Image.PreserveAspectFit
  45. source: details === null ? "" : (details.icon_url || "../../images/placeholder.svg")
  46. mipmap: true
  47. height: UM.Theme.getSize("toolbox_thumbnail_large").height - 4 * UM.Theme.getSize("default_margin").height
  48. width: UM.Theme.getSize("toolbox_thumbnail_large").height - 4 * UM.Theme.getSize("default_margin").height
  49. sourceSize.height: height
  50. sourceSize.width: width
  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. }
  62. text: details === null ? "" : (details.name || "")
  63. font: UM.Theme.getFont("large_bold")
  64. color: UM.Theme.getColor("text")
  65. width: contentWidth
  66. height: contentHeight
  67. renderType: Text.NativeRendering
  68. }
  69. Column
  70. {
  71. id: properties
  72. anchors
  73. {
  74. top: title.bottom
  75. left: title.left
  76. topMargin: UM.Theme.getSize("default_margin").height
  77. }
  78. spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
  79. width: childrenRect.width
  80. height: childrenRect.height
  81. Label
  82. {
  83. text: catalog.i18nc("@label", "Version") + ":"
  84. font: UM.Theme.getFont("default")
  85. color: UM.Theme.getColor("text_medium")
  86. renderType: Text.NativeRendering
  87. }
  88. Label
  89. {
  90. text: catalog.i18nc("@label", "Last updated") + ":"
  91. font: UM.Theme.getFont("default")
  92. color: UM.Theme.getColor("text_medium")
  93. renderType: Text.NativeRendering
  94. }
  95. Label
  96. {
  97. text: catalog.i18nc("@label", "Brand") + ":"
  98. font: UM.Theme.getFont("default")
  99. color: UM.Theme.getColor("text_medium")
  100. renderType: Text.NativeRendering
  101. }
  102. Label
  103. {
  104. text: catalog.i18nc("@label", "Downloads") + ":"
  105. font: UM.Theme.getFont("default")
  106. color: UM.Theme.getColor("text_medium")
  107. renderType: Text.NativeRendering
  108. }
  109. }
  110. Column
  111. {
  112. id: values
  113. anchors
  114. {
  115. top: title.bottom
  116. left: properties.right
  117. leftMargin: UM.Theme.getSize("default_margin").width
  118. topMargin: UM.Theme.getSize("default_margin").height
  119. }
  120. spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
  121. height: childrenRect.height
  122. Label
  123. {
  124. text: details === null ? "" : (details.version || catalog.i18nc("@label", "Unknown"))
  125. font: UM.Theme.getFont("default")
  126. color: UM.Theme.getColor("text")
  127. renderType: Text.NativeRendering
  128. }
  129. Label
  130. {
  131. text:
  132. {
  133. if (details === null)
  134. {
  135. return ""
  136. }
  137. var date = new Date(details.last_updated)
  138. return date.toLocaleString(UM.Preferences.getValue("general/language"))
  139. }
  140. font: UM.Theme.getFont("default")
  141. color: UM.Theme.getColor("text")
  142. renderType: Text.NativeRendering
  143. }
  144. Label
  145. {
  146. text:
  147. {
  148. if (details === null)
  149. {
  150. return ""
  151. }
  152. else
  153. {
  154. return "<a href=\"" + details.website + "\">" + details.author_name + "</a>"
  155. }
  156. }
  157. font: UM.Theme.getFont("default")
  158. color: UM.Theme.getColor("text")
  159. linkColor: UM.Theme.getColor("text_link")
  160. onLinkActivated: UM.UrlUtil.openUrl(link, ["http", "https"])
  161. renderType: Text.NativeRendering
  162. }
  163. Label
  164. {
  165. text: details === null ? "" : (details.download_count || catalog.i18nc("@label", "Unknown"))
  166. font: UM.Theme.getFont("default")
  167. color: UM.Theme.getColor("text")
  168. renderType: Text.NativeRendering
  169. }
  170. }
  171. }
  172. ToolboxDetailList
  173. {
  174. anchors
  175. {
  176. top: header.bottom
  177. bottom: page.bottom
  178. left: header.left
  179. right: page.right
  180. }
  181. }
  182. }