1
0

feat: hide leaderboard when no users

This commit is contained in:
2026-06-05 20:26:53 +08:00
parent 2fca74c690
commit 9f98b2cf4e
2 changed files with 23 additions and 9 deletions
@@ -79,20 +79,23 @@ Rectangle {
}
}
Label {
Layout.alignment: Qt.AlignHCenter
font.pixelSize: UIStyle.fontSizeL
color: UIStyle.titletextColor
text: "Leaderboard"
}
ColumnLayout {
Layout.fillHeight: true
Layout.fillWidth: true
spacing: -1
visible: leaderboard.hasRow
Label {
Layout.alignment: Qt.AlignHCenter
padding: 10
font.pixelSize: UIStyle.fontSizeL
color: UIStyle.titletextColor
text: "Leaderboard"
}
HorizontalHeaderView {
Layout.fillWidth: true
syncView: tableView
+11
View File
@@ -154,6 +154,8 @@ class GameService(QObject):
@QmlElement
class SqlLeaderboardModel(QSqlTableModel):
selected = Signal()
def __init__(self, parent=None):
super().__init__(parent)
@@ -164,6 +166,15 @@ class SqlLeaderboardModel(QSqlTableModel):
self.select()
def select(self, /):
result = super().select()
self.selected.emit()
return result
@Property(bool, notify=selected)
def hasRow(self):
return self.rowCount() > 0
def main():
logging.basicConfig(level=logging.DEBUG)