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 }
}
}