Skip to content

Commit

Permalink
修复对局生涯界面因召唤师名字换行以及对局数量不足 11 产生的各种显示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Nov 7, 2023
1 parent c2cbba0 commit b7dc8e1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/view/game_info_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,22 @@ def __init__(self, summoner, parent=None):
self.summonerName.clicked.connect(lambda: self.parent().parent(
).parent().summonerGamesClicked.emit(self.summonerName.text()))

# self.summonerName.setFixedHeight(35)

warped = False

if QWidget().fontMetrics().size(Qt.TextSingleLine, name).width() > 50 and len(name) > 8:
pos = (len(name)+1) // 2
name = name[:pos] + "\n" + name[pos:]
self.summonerName.setText(name)
warped = True

sp1, sp2 = (-2, 2) if warped else (8, 11)

self.vBoxLayout.addSpacing(5)
self.vBoxLayout.addSpacing(sp1)
self.vBoxLayout.addWidget(self.summonerName, alignment=Qt.AlignCenter)
self.vBoxLayout.addSpacing(10)
self.vBoxLayout.addSpacing(sp2)

self.vBoxLayout.addLayout(self.gamesLayout)
self.gamesLayout.setContentsMargins(0, 0, 0, 0)

Expand All @@ -543,8 +551,8 @@ def __init__(self, summoner, parent=None):
self.gamesLayout.addWidget(tab, stretch=1)

if len(games) < 11:
self.gamesLayout.addSpacing(5)
self.gamesLayout.addStretch(11-len(games))
self.gamesLayout.addSpacing(5)


class GameTab(QFrame):
Expand Down

0 comments on commit b7dc8e1

Please sign in to comment.