1
0

feat: add leaderboard

This commit is contained in:
2026-06-05 01:33:51 +08:00
parent e11f48d93b
commit 1b10d2841f
3 changed files with 99 additions and 26 deletions
@@ -13,6 +13,7 @@ Rectangle {
color: UIStyle.background
required property SqlLeaderboardModel leaderboard
required property ListModel rounds
property QtObject selectedRound
@@ -66,41 +67,80 @@ Rectangle {
}
}
TableView {
Label {
Layout.alignment: Qt.AlignHCenter
font.pixelSize: UIStyle.fontSizeL
color: UIStyle.titletextColor
text: "Leaderboard"
}
ColumnLayout {
Layout.fillHeight: true
Layout.fillWidth: true
spacing: -1
columnSpacing: 1
rowSpacing: 1
HorizontalHeaderView {
Layout.fillWidth: true
syncView: tableView
clip: true
columnSpacing: -1
rowSpacing: -1
boundsBehavior: Flickable.StopAtBounds
delegate: Rectangle {
border.width: 1
implicitHeight: 50
implicitWidth: 100
rowHeightProvider: function (row) {
return 35
}
Text {
anchors.centerIn: parent
text: display
delegate: Rectangle {
border.width: 1
color: "#f1f1f1"
Text {
anchors.centerIn: parent
font.bold: true
text: display
}
}
}
model: TableModel {
rows: [
{
User: "me",
Score: "1"
}
]
TableView {
id: tableView
TableModelColumn {
display: "User"
Layout.fillHeight: true
Layout.fillWidth: true
clip: true
columnSpacing: -1
rowSpacing: -1
boundsBehavior: Flickable.StopAtBounds
model: leaderboard
columnWidthProvider: function (column) {
if (column === 0)
return tableView.width * 0.6
return tableView.width * 0.4
}
rowHeightProvider: function (row) {
return 35
}
TableModelColumn {
display: "Score"
onWidthChanged: tableView.forceLayout()
delegate: Rectangle {
border.width: 1
Text {
anchors.centerIn: parent
text: display
}
}
}
}
Item { Layout.fillHeight: true }
}
}
+10 -4
View File
@@ -18,11 +18,11 @@ ApplicationWindow {
ListElement {
name: "Round 1"
mode: GameService.GameScoring.FirstGuess
item_id: 100
item_name: "Item 1"
mode: GameService.GameScoring.FirstGuessThenHighestAmount
item_id: 1061153
item_name: "Dreamweave Silk Selection Gift Box"
item_image: ""
clue: "Clue 1"
clue: "Dreamweave Silk Selection Gift Box"
}
ListElement {
name: "Round 2"
@@ -50,11 +50,16 @@ ApplicationWindow {
}
}
SqlLeaderboardModel {
id: leaderboard
}
IdleView {
id: idleView
anchors.fill: parent
leaderboard: leaderboard
rounds: rounds
selectedRound: rounds.get(0)
onRoundSelected: {
@@ -75,6 +80,7 @@ ApplicationWindow {
onClose: {
idleView.visible = true
ongoingView.visible = false
leaderboard.select()
}
}