PlayerListItem.qml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. Rectangle {
  4. id: root
  5. property var colors: ({
  6. })
  7. property var playerData: ({
  8. })
  9. property var teamIcons: []
  10. property bool canRemove: true
  11. signal removeClicked()
  12. signal colorClicked()
  13. signal teamClicked()
  14. signal factionClicked()
  15. width: parent ? parent.width : 400
  16. height: 48
  17. radius: 6
  18. color: colors.cardBaseB
  19. border.color: colors.thumbBr
  20. border.width: 1
  21. Row {
  22. anchors.fill: parent
  23. anchors.margins: 8
  24. spacing: 10
  25. Item {
  26. width: 80
  27. height: parent.height
  28. Text {
  29. anchors.centerIn: parent
  30. text: playerData.playerName || ""
  31. color: playerData.isHuman ? colors.addColor : colors.textMain
  32. font.pixelSize: 14
  33. font.bold: playerData.isHuman || false
  34. }
  35. }
  36. Rectangle {
  37. width: 90
  38. height: parent.height
  39. radius: 4
  40. color: playerData.colorHex || "#666666"
  41. border.color: Qt.lighter(playerData.colorHex || "#666666", 1.3)
  42. border.width: 1
  43. Text {
  44. anchors.centerIn: parent
  45. text: playerData.colorName || "Color"
  46. color: "white"
  47. font.pixelSize: 11
  48. font.bold: true
  49. style: Text.Outline
  50. styleColor: "black"
  51. }
  52. MouseArea {
  53. anchors.fill: parent
  54. cursorShape: Qt.PointingHandCursor
  55. onClicked: root.colorClicked()
  56. }
  57. ToolTip {
  58. visible: parent.children[1].containsMouse
  59. text: "Click to change color"
  60. delay: 500
  61. }
  62. }
  63. Rectangle {
  64. width: 50
  65. height: parent.height
  66. radius: 4
  67. color: colors.hoverBg
  68. border.color: colors.thumbBr
  69. border.width: 1
  70. Column {
  71. anchors.centerIn: parent
  72. spacing: 2
  73. Text {
  74. anchors.horizontalCenter: parent.horizontalCenter
  75. text: {
  76. if (!playerData.team_id || !teamIcons || teamIcons.length === 0)
  77. return "●";
  78. return teamIcons[(playerData.team_id - 1) % teamIcons.length];
  79. }
  80. color: colors.textMain
  81. font.pixelSize: 18
  82. }
  83. Text {
  84. anchors.horizontalCenter: parent.horizontalCenter
  85. text: "T" + (playerData.team_id || 1)
  86. color: colors.textSubLite
  87. font.pixelSize: 9
  88. }
  89. }
  90. MouseArea {
  91. anchors.fill: parent
  92. cursorShape: Qt.PointingHandCursor
  93. hoverEnabled: true
  94. onClicked: root.teamClicked()
  95. }
  96. ToolTip {
  97. visible: parent.children[1].containsMouse
  98. text: "Click to change team"
  99. delay: 500
  100. }
  101. }
  102. Rectangle {
  103. width: 140
  104. height: parent.height
  105. radius: 4
  106. color: colors.cardBaseA
  107. border.color: colors.thumbBr
  108. border.width: 1
  109. opacity: 0.7
  110. Text {
  111. anchors.centerIn: parent
  112. text: playerData.factionName || "Standard of Iron"
  113. color: colors.textSub
  114. font.pixelSize: 11
  115. elide: Text.ElideRight
  116. width: parent.width - 8
  117. horizontalAlignment: Text.AlignHCenter
  118. }
  119. MouseArea {
  120. anchors.fill: parent
  121. cursorShape: Qt.ArrowCursor
  122. enabled: false
  123. onClicked: root.factionClicked()
  124. }
  125. }
  126. Item {
  127. width: Math.max(10, parent.parent.width - 432)
  128. height: parent.height
  129. }
  130. Rectangle {
  131. width: 32
  132. height: parent.height
  133. radius: 4
  134. color: removeMouseArea.containsMouse ? colors.dangerColor : colors.cardBaseA
  135. border.color: colors.dangerColor
  136. border.width: 1
  137. visible: root.canRemove && !playerData.isHuman
  138. Text {
  139. anchors.centerIn: parent
  140. text: "✕"
  141. color: "white"
  142. font.pixelSize: 16
  143. font.bold: true
  144. }
  145. MouseArea {
  146. id: removeMouseArea
  147. anchors.fill: parent
  148. hoverEnabled: true
  149. cursorShape: Qt.PointingHandCursor
  150. onClicked: root.removeClicked()
  151. }
  152. ToolTip {
  153. visible: removeMouseArea.containsMouse
  154. text: "Remove player"
  155. delay: 300
  156. }
  157. Behavior on color {
  158. ColorAnimation {
  159. duration: 150
  160. }
  161. }
  162. }
  163. }
  164. }