T_Home.qml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. import QtQuick
  2. import QtQuick.Layouts
  3. import QtQuick.Window
  4. import QtQuick.Controls
  5. import "qrc:///example/qml/global/"
  6. import FluentUI
  7. FluScrollablePage{
  8. leftPadding:10
  9. rightPadding:0
  10. bottomPadding:20
  11. ListModel{
  12. id:model_header
  13. ListElement{
  14. icon:"qrc:/example/res/image/ic_home_github.png"
  15. title:"FluentUI GitHub"
  16. desc:"The latest FluentUI controls and styles for your applications."
  17. url:"https://github.com/zhuzichu520/FluentUI"
  18. }
  19. }
  20. Item{
  21. Layout.fillWidth: true
  22. height: 320
  23. Image {
  24. fillMode:Image.PreserveAspectCrop
  25. anchors.fill: parent
  26. verticalAlignment: Qt.AlignTop
  27. source: "qrc:/example/res/image/bg_home_header.png"
  28. }
  29. Rectangle{
  30. anchors.fill: parent
  31. gradient: Gradient{
  32. GradientStop { position: 0.8; color: FluTheme.dark ? Qt.rgba(0,0,0,0) : Qt.rgba(1,1,1,0) }
  33. GradientStop { position: 1.0; color: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1) }
  34. }
  35. }
  36. FluText{
  37. text:"FluentUI Gallery"
  38. font: FluTextStyle.TitleLarge
  39. anchors{
  40. top: parent.top
  41. left: parent.left
  42. topMargin: 20
  43. leftMargin: 20
  44. }
  45. }
  46. ListView{
  47. anchors{
  48. left: parent.left
  49. right: parent.right
  50. bottom: parent.bottom
  51. }
  52. orientation: ListView.Horizontal
  53. height: 240
  54. model: model_header
  55. header: Item{height: 10;width: 10}
  56. footer: Item{height: 10;width: 10}
  57. ScrollBar.horizontal: FluScrollBar{
  58. id: scrollbar_header
  59. }
  60. clip: false
  61. delegate:Item{
  62. width: 220
  63. height: 240
  64. FluArea{
  65. radius: 8
  66. width: 200
  67. height: 220
  68. anchors.centerIn: parent
  69. Rectangle{
  70. anchors.fill: parent
  71. radius: 8
  72. color:{
  73. if(FluTheme.dark){
  74. if(item_mouse.containsMouse){
  75. return Qt.rgba(1,1,1,0.03)
  76. }
  77. return Qt.rgba(0,0,0,0)
  78. }else{
  79. if(item_mouse.containsMouse){
  80. return Qt.rgba(0,0,0,0.03)
  81. }
  82. return Qt.rgba(0,0,0,0)
  83. }
  84. }
  85. }
  86. ColumnLayout{
  87. Image {
  88. Layout.topMargin: 20
  89. Layout.leftMargin: 20
  90. Layout.preferredWidth: 50
  91. Layout.preferredHeight: 50
  92. source: model.icon
  93. }
  94. FluText{
  95. text: model.title
  96. font: FluTextStyle.Body
  97. Layout.topMargin: 20
  98. Layout.leftMargin: 20
  99. }
  100. FluText{
  101. text: model.desc
  102. Layout.topMargin: 5
  103. Layout.preferredWidth: 160
  104. Layout.leftMargin: 20
  105. color: FluColors.Grey120
  106. font.pixelSize: 12
  107. wrapMode: Text.WrapAnywhere
  108. }
  109. }
  110. FluIcon{
  111. iconSource: FluentIcons.OpenInNewWindow
  112. iconSize: 15
  113. anchors{
  114. bottom: parent.bottom
  115. right: parent.right
  116. rightMargin: 10
  117. bottomMargin: 10
  118. }
  119. }
  120. MouseArea{
  121. id:item_mouse
  122. anchors.fill: parent
  123. hoverEnabled: true
  124. onWheel: (wheel)=>{
  125. if (wheel.angleDelta.y > 0) scrollbar_header.decrease()
  126. else scrollbar_header.increase()
  127. }
  128. onClicked: {
  129. Qt.openUrlExternally(model.url)
  130. }
  131. }
  132. }
  133. }
  134. }
  135. }
  136. Component{
  137. id:com_item
  138. Item{
  139. width: 320
  140. height: 120
  141. FluArea{
  142. radius: 8
  143. width: 300
  144. height: 100
  145. anchors.centerIn: parent
  146. Rectangle{
  147. anchors.fill: parent
  148. radius: 8
  149. color:{
  150. if(FluTheme.dark){
  151. if(item_mouse.containsMouse){
  152. return Qt.rgba(1,1,1,0.03)
  153. }
  154. return Qt.rgba(0,0,0,0)
  155. }else{
  156. if(item_mouse.containsMouse){
  157. return Qt.rgba(0,0,0,0.03)
  158. }
  159. return Qt.rgba(0,0,0,0)
  160. }
  161. }
  162. }
  163. Image{
  164. id:item_icon
  165. height: 40
  166. width: 40
  167. source: modelData.image
  168. anchors{
  169. left: parent.left
  170. leftMargin: 20
  171. verticalCenter: parent.verticalCenter
  172. }
  173. }
  174. FluText{
  175. id:item_title
  176. text:modelData.title
  177. font: FluTextStyle.BodyStrong
  178. anchors{
  179. left: item_icon.right
  180. leftMargin: 20
  181. top: item_icon.top
  182. }
  183. }
  184. FluText{
  185. id:item_desc
  186. text:modelData.desc
  187. color:FluColors.Grey120
  188. wrapMode: Text.WrapAnywhere
  189. elide: Text.ElideRight
  190. font: FluTextStyle.Caption
  191. maximumLineCount: 2
  192. anchors{
  193. left: item_title.left
  194. right: parent.right
  195. rightMargin: 20
  196. top: item_title.bottom
  197. topMargin: 5
  198. }
  199. }
  200. Rectangle{
  201. height: 12
  202. width: 12
  203. radius: 6
  204. color: FluTheme.primaryColor.dark
  205. anchors{
  206. right: parent.right
  207. top: parent.top
  208. rightMargin: 14
  209. topMargin: 14
  210. }
  211. }
  212. MouseArea{
  213. id:item_mouse
  214. anchors.fill: parent
  215. hoverEnabled: true
  216. onClicked: {
  217. ItemsOriginal.startPageByItem(modelData)
  218. }
  219. }
  220. }
  221. }
  222. }
  223. FluText{
  224. text: "Recently added samples"
  225. font: FluTextStyle.Title
  226. Layout.topMargin: 20
  227. Layout.leftMargin: 20
  228. }
  229. GridView{
  230. Layout.fillWidth: true
  231. implicitHeight: contentHeight
  232. cellHeight: 120
  233. cellWidth: 320
  234. model:ItemsOriginal.getRecentlyAddedData()
  235. interactive: false
  236. delegate: com_item
  237. }
  238. FluText{
  239. text: "Recently updated samples"
  240. font: FluTextStyle.Title
  241. Layout.topMargin: 20
  242. Layout.leftMargin: 20
  243. }
  244. GridView{
  245. Layout.fillWidth: true
  246. implicitHeight: contentHeight
  247. cellHeight: 120
  248. cellWidth: 320
  249. interactive: false
  250. model: ItemsOriginal.getRecentlyUpdatedData()
  251. delegate: com_item
  252. }
  253. }