2
0

MapListPanel.qml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. Item {
  4. id: root
  5. property var mapsModel: []
  6. property int currentIndex: 0
  7. property var colors: ({
  8. })
  9. signal mapSelected(int index)
  10. signal mapDoubleClicked()
  11. function field(obj, key) {
  12. return (obj && obj[key] !== undefined) ? String(obj[key]) : "";
  13. }
  14. anchors.fill: parent
  15. Text {
  16. id: title
  17. text: "Maps"
  18. color: colors.textMain
  19. font.pixelSize: 18
  20. font.bold: true
  21. anchors {
  22. top: parent.top
  23. left: parent.left
  24. right: parent.right
  25. }
  26. }
  27. Text {
  28. id: countLabel
  29. text: "(" + (list.count || 0) + ")"
  30. color: colors.textSubLite
  31. font.pixelSize: 12
  32. anchors {
  33. left: title.right
  34. leftMargin: 8
  35. verticalCenter: title.verticalCenter
  36. }
  37. }
  38. Rectangle {
  39. id: listFrame
  40. color: "transparent"
  41. radius: 10
  42. border.color: colors.panelBr
  43. border.width: 1
  44. clip: true
  45. anchors {
  46. top: title.bottom
  47. topMargin: 12
  48. left: parent.left
  49. right: parent.right
  50. bottom: parent.bottom
  51. }
  52. ListView {
  53. id: list
  54. anchors.fill: parent
  55. anchors.margins: 8
  56. model: root.mapsModel
  57. clip: true
  58. spacing: 8
  59. currentIndex: root.currentIndex
  60. keyNavigationWraps: false
  61. boundsBehavior: Flickable.StopAtBounds
  62. onCurrentIndexChanged: {
  63. root.currentIndex = currentIndex;
  64. if (currentIndex >= 0)
  65. root.mapSelected(currentIndex);
  66. }
  67. highlightMoveDuration: 120
  68. highlightFollowsCurrentItem: true
  69. Item {
  70. anchors.fill: parent
  71. visible: list.count === 0
  72. Text {
  73. text: "No maps available"
  74. color: colors.textSub
  75. font.pixelSize: 14
  76. anchors.centerIn: parent
  77. }
  78. }
  79. ScrollBar.vertical: ScrollBar {
  80. policy: ScrollBar.AsNeeded
  81. }
  82. highlight: Rectangle {
  83. color: "transparent"
  84. radius: 8
  85. border.color: colors.selectedBr
  86. border.width: 1
  87. }
  88. delegate: Item {
  89. width: list.width
  90. height: 68
  91. MouseArea {
  92. id: rowMouse
  93. anchors.fill: parent
  94. hoverEnabled: true
  95. acceptedButtons: Qt.LeftButton
  96. cursorShape: Qt.PointingHandCursor
  97. onClicked: list.currentIndex = index
  98. onDoubleClicked: root.mapDoubleClicked()
  99. }
  100. Rectangle {
  101. anchors.fill: parent
  102. radius: 8
  103. clip: true
  104. color: rowMouse.containsPress ? colors.hoverBg : (index === list.currentIndex ? colors.selectedBg : (rowMouse.containsMouse ? Qt.rgba(1, 1, 1, 0.03) : "transparent"))
  105. border.width: 1
  106. border.color: (index === list.currentIndex) ? colors.selectedBr : (rowMouse.containsMouse ? Qt.rgba(1, 1, 1, 0.15) : colors.thumbBr)
  107. Rectangle {
  108. id: thumbWrap
  109. width: 60
  110. height: 42
  111. radius: 6
  112. color: "#031314"
  113. border.color: colors.thumbBr
  114. border.width: 1
  115. clip: true
  116. anchors {
  117. left: parent.left
  118. leftMargin: 10
  119. verticalCenter: parent.verticalCenter
  120. }
  121. Image {
  122. anchors.fill: parent
  123. source: (typeof thumbnail !== "undefined") ? thumbnail : ""
  124. asynchronous: true
  125. fillMode: Image.PreserveAspectCrop
  126. visible: status === Image.Ready
  127. }
  128. }
  129. Column {
  130. spacing: 4
  131. anchors {
  132. left: thumbWrap.right
  133. leftMargin: 10
  134. right: parent.right
  135. rightMargin: 10
  136. verticalCenter: parent.verticalCenter
  137. }
  138. Text {
  139. text: (typeof name !== "undefined") ? String(name) : ""
  140. color: (index === list.currentIndex) ? "white" : "#dff0ff"
  141. font.pixelSize: (index === list.currentIndex) ? 15 : 14
  142. font.bold: (index === list.currentIndex)
  143. elide: Text.ElideRight
  144. width: parent.width
  145. }
  146. Text {
  147. text: (typeof description !== "undefined") ? String(description) : ""
  148. color: (index === list.currentIndex) ? "#d0e8ff" : colors.textSub
  149. font.pixelSize: 11
  150. elide: Text.ElideRight
  151. width: parent.width
  152. }
  153. }
  154. Behavior on color {
  155. ColorAnimation {
  156. duration: 160
  157. }
  158. }
  159. Behavior on border.color {
  160. ColorAnimation {
  161. duration: 160
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. }