ToolboxDetailPage.qml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 || {}
  11. anchors.fill: parent
  12. ToolboxBackColumn
  13. {
  14. id: sidebar
  15. }
  16. Item
  17. {
  18. id: header
  19. anchors
  20. {
  21. left: sidebar.right
  22. right: parent.right
  23. rightMargin: UM.Theme.getSize("wide_margin").width
  24. }
  25. height: UM.Theme.getSize("toolbox_detail_header").height
  26. Rectangle
  27. {
  28. id: thumbnail
  29. width: UM.Theme.getSize("toolbox_thumbnail_medium").width
  30. height: UM.Theme.getSize("toolbox_thumbnail_medium").height
  31. anchors
  32. {
  33. top: parent.top
  34. left: parent.left
  35. leftMargin: UM.Theme.getSize("wide_margin").width
  36. topMargin: UM.Theme.getSize("wide_margin").height
  37. }
  38. color: "white" //Always a white background for image (regardless of theme).
  39. Image
  40. {
  41. anchors.fill: parent
  42. fillMode: Image.PreserveAspectFit
  43. source: details === null ? "" : (details.icon_url || "../images/logobot.svg")
  44. mipmap: true
  45. }
  46. }
  47. Label
  48. {
  49. id: title
  50. anchors
  51. {
  52. top: thumbnail.top
  53. left: thumbnail.right
  54. leftMargin: UM.Theme.getSize("default_margin").width
  55. right: parent.right
  56. rightMargin: UM.Theme.getSize("wide_margin").width
  57. bottomMargin: UM.Theme.getSize("default_margin").height
  58. }
  59. text: details === null ? "" : (details.name || "")
  60. font: UM.Theme.getFont("large")
  61. color: UM.Theme.getColor("text")
  62. wrapMode: Text.WordWrap
  63. width: parent.width
  64. height: UM.Theme.getSize("toolbox_property_label").height
  65. }
  66. Column
  67. {
  68. id: properties
  69. anchors
  70. {
  71. top: title.bottom
  72. left: title.left
  73. topMargin: UM.Theme.getSize("default_margin").height
  74. }
  75. spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
  76. width: childrenRect.width
  77. height: childrenRect.height
  78. Label
  79. {
  80. text: catalog.i18nc("@label", "Version") + ":"
  81. font: UM.Theme.getFont("default")
  82. color: UM.Theme.getColor("text_medium")
  83. }
  84. Label
  85. {
  86. text: catalog.i18nc("@label", "Last updated") + ":"
  87. font: UM.Theme.getFont("default")
  88. color: UM.Theme.getColor("text_medium")
  89. }
  90. Label
  91. {
  92. text: catalog.i18nc("@label", "Author") + ":"
  93. font: UM.Theme.getFont("default")
  94. color: UM.Theme.getColor("text_medium")
  95. }
  96. Label
  97. {
  98. text: catalog.i18nc("@label", "Downloads") + ":"
  99. font: UM.Theme.getFont("default")
  100. color: UM.Theme.getColor("text_medium")
  101. }
  102. }
  103. Column
  104. {
  105. id: values
  106. anchors
  107. {
  108. top: title.bottom
  109. left: properties.right
  110. leftMargin: UM.Theme.getSize("default_margin").width
  111. topMargin: UM.Theme.getSize("default_margin").height
  112. }
  113. spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
  114. height: childrenRect.height
  115. Label
  116. {
  117. text: details === null ? "" : (details.version || catalog.i18nc("@label", "Unknown"))
  118. font: UM.Theme.getFont("default")
  119. color: UM.Theme.getColor("text")
  120. }
  121. Label
  122. {
  123. text:
  124. {
  125. if (details === null)
  126. {
  127. return ""
  128. }
  129. var date = new Date(details.last_updated)
  130. return date.toLocaleString(UM.Preferences.getValue("general/language"))
  131. }
  132. font: UM.Theme.getFont("default")
  133. color: UM.Theme.getColor("text")
  134. }
  135. Label
  136. {
  137. text:
  138. {
  139. if (details === null)
  140. {
  141. return ""
  142. }
  143. else
  144. {
  145. return "<a href=\"" + details.website + "\">" + details.author_name + "</a>"
  146. }
  147. }
  148. font: UM.Theme.getFont("default")
  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 === null ? "" : (details.download_count || catalog.i18nc("@label", "Unknown"))
  156. font: UM.Theme.getFont("default")
  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. }