Skip to content

Commit

Permalink
将生涯界面中的召唤师编号放在名字下面
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Dec 29, 2023
1 parent b3fcd0b commit 1e9c2d0
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 42 deletions.
5 changes: 3 additions & 2 deletions app/lol/entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ def __init__(self, data: dict):
self.xpSinceLastLevel = data['xpSinceLastLevel']
self.xpUntilNextLevel = data['xpUntilNextLevel']
self.isPublic = data["privacy"] == "PUBLIC"
self.tagLine = data.get("tagLine", "")
self.completeName = "#".join((self.name, self.tagLine)) if self.tagLine else self.name # 兼容外服
self.tagLine = data.get("tagLine")
self.completeName = "#".join(
(self.name, self.tagLine)) if self.tagLine else self.name # 兼容外服
5 changes: 5 additions & 0 deletions app/resource/qss/dark/career_interface.qss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ QLabel#name {
font: bold 32px 'Segoe UI', 'Microsoft YaHei';
}

QLabel#tagLineLabel {
font: 16px;
color: rgb(200, 200, 200);
}

QLabel#rencent20GamesLabel,
QLabel#winsLabel,
QLabel#lossesLabel,
Expand Down
5 changes: 5 additions & 0 deletions app/resource/qss/light/career_interface.qss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ QLabel#name {
font: bold 32px 'Microsoft YaHei', 'Segoe UI';
}

QLabel#tagLineLabel {
font: 16px;
color: rgb(100, 100, 100);
}

QLabel#level {
font: 14px 'Segoe UI', 'Microsoft YaHei';
}
Expand Down
30 changes: 27 additions & 3 deletions app/view/career_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def text(self) -> str:
return super().text().replace("🫣", '')


class TagLineLabel(QLabel):
def text(self) -> str:
return super().text().replace(" ", '')


class CareerInterface(SmoothScrollArea):
careerInfoChanged = pyqtSignal(dict)
showLoadingPage = pyqtSignal()
Expand All @@ -43,6 +48,7 @@ def __init__(self, parent=None):
super().__init__(parent)
self.currentSummonerName = None
self.puuid = None
self.showTagLine = False

self.vBoxLayout = QVBoxLayout(self)
self.IconNameHBoxLayout = QHBoxLayout()
Expand All @@ -52,8 +58,10 @@ def __init__(self, parent=None):
1,
parent=self)
self.name = NameLabel(self.tr("Connecting..."))
self.tagLineLabel = TagLineLabel()
self.copyButton = ToolButton(Icon.COPY)
self.nameButtonLayout = QHBoxLayout()
self.nameTagLineLayout = QVBoxLayout()

self.buttonsLayout = QVBoxLayout()
self.backToMeButton = PushButton(self.tr("Back to me"))
Expand Down Expand Up @@ -90,14 +98,17 @@ def __init__(self, parent=None):
self.__connectSignalToSlot()

def __initWidget(self):
self.tagLineLabel.setVisible(False)
self.tagLineLabel.setAlignment(Qt.AlignCenter)

self.copyButton.setFixedSize(26, 26)
self.copyButton.setEnabled(False)
self.copyButton.setToolTip(self.tr("Copy summoner name to ClipBoard"))
self.copyButton.installEventFilter(
ToolTipFilter(self.copyButton, 500, ToolTipPosition.TOP))

self.name.setObjectName("name")
# self.level.setObjectName("level")
self.tagLineLabel.setObjectName("tagLineLabel")
self.nameLevelVLayout.setObjectName("nameLevelVLayout")

self.recent20GamesLabel.setObjectName('rencent20GamesLabel')
Expand Down Expand Up @@ -161,8 +172,13 @@ def __initWidget(self):
self.initTableStyle()

def __initLayout(self):
self.nameTagLineLayout.setContentsMargins(0, 0, 0, 0)
self.nameTagLineLayout.addWidget(self.name)
self.nameTagLineLayout.addWidget(self.tagLineLabel)
self.nameTagLineLayout.setSpacing(0)

self.nameButtonLayout.setContentsMargins(0, 0, 0, 0)
self.nameButtonLayout.addWidget(self.name)
self.nameButtonLayout.addLayout(self.nameTagLineLayout)
self.nameButtonLayout.addSpacing(5)
self.nameButtonLayout.addWidget(self.copyButton)

Expand Down Expand Up @@ -251,6 +267,7 @@ def __setLoadingPageEnabled(self, enable):
self.winsLabel.setVisible(not enable)
self.lossesLabel.setVisible(not enable)
self.gameInfoArea.setVisible(not enable)
self.tagLineLabel.setVisible(not enable and self.showTagLine)

self.progressRing.setVisible(enable)

Expand Down Expand Up @@ -305,7 +322,7 @@ def __connectSignalToSlot(self):
self.filterComboBox.currentIndexChanged.connect(
self.__onfilterComboBoxChanged)
self.copyButton.clicked.connect(
lambda: pyperclip.copy(self.name.text()))
lambda: pyperclip.copy(self.getSummonerName()))

self.hideLoadingPage.connect(
lambda: self.__setLoadingPageEnabled(False))
Expand Down Expand Up @@ -343,6 +360,10 @@ def __onCareerInfoChanged(self, info: dict):
rankInfo = info['rankInfo']
games = info['games']

if info['tagLine'] != None:
self.showTagLine = True
self.tagLineLabel.setText(f"# {info['tagLine']}")

levelStr = str(level) if level != -1 else "None"
self.icon.updateIcon(icon, xpSinceLastLevel,
xpUntilNextLevel, levelStr)
Expand Down Expand Up @@ -533,6 +554,9 @@ def __onfilterComboBoxChanged(self, index):
def setCurrentSummonerName(self, name):
self.currentSummonerName = name

def getSummonerName(self):
return self.name.text() if not self.showTagLine else f'{self.name.text()}{self.tagLineLabel.text()}'

def isCurrentSummoner(self):

return self.currentSummonerName == None or self.currentSummonerName == self.name.text()
Expand Down
84 changes: 47 additions & 37 deletions app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,11 @@ def __changeCareerToCurrentSummoner(self):

iconId = self.currentSummoner.profileIconId
icon = connector.getProfileIcon(iconId)
name = self.currentSummoner.completeName
name = self.currentSummoner.name
level = self.currentSummoner.level
xpSinceLastLevel = self.currentSummoner.xpSinceLastLevel
xpUntilNextLevel = self.currentSummoner.xpUntilNextLevel
tagLine = self.currentSummoner.tagLine

self.careerInterface.currentSummonerName = name

Expand Down Expand Up @@ -429,7 +430,8 @@ def __changeCareerToCurrentSummoner(self):
'games': games,
'champions': champions,
'triggerByUser': True,
'isPublic': self.currentSummoner.isPublic
'isPublic': self.currentSummoner.isPublic,
'tagLine': tagLine
}
if champions:
emitInfo["champions"] = champions
Expand Down Expand Up @@ -512,7 +514,8 @@ def __onCurrentSummonerProfileChanged(self, data: dict):
self.currentSummoner = Summoner(data)

def _():
name = self.currentSummoner.completeName
name = self.currentSummoner.name
tagLine = self.currentSummoner.tagLine

iconId = self.currentSummoner.profileIconId
icon = connector.getProfileIcon(iconId)
Expand All @@ -522,13 +525,15 @@ def _():

self.nameOrIconChanged.emit(icon, name)
self.careerInterface.IconLevelExpChanged.emit(
{'name': name,
'icon': icon,
'level': level,
'xpSinceLastLevel': xpSinceLastLevel,
'xpUntilNextLevel': xpUntilNextLevel,
'isPublic': self.currentSummoner.isPublic
}
{
'name': name,
'icon': icon,
'level': level,
'xpSinceLastLevel': xpSinceLastLevel,
'xpUntilNextLevel': xpUntilNextLevel,
'isPublic': self.currentSummoner.isPublic,
'tagLine': tagLine,
}
)

threading.Thread(target=_).start()
Expand Down Expand Up @@ -629,7 +634,7 @@ def closeEvent(self, a0) -> None:
self.hide()

def __onCareerInterfaceHistoryButtonClicked(self):
summonerName = self.careerInterface.name.text()
summonerName = self.careerInterface.getSummonerName()

self.searchInterface.searchLineEdit.setText(summonerName)
self.searchInterface.searchLineEdit.searchButton.clicked.emit()
Expand Down Expand Up @@ -694,7 +699,7 @@ def _():
champions = getRecentChampions(games['games'])

emitInfo = {
'name': name,
'name': summoner.name,
'icon': icon,
'level': level,
'xpSinceLastLevel': xpSinceLastLevel,
Expand All @@ -703,7 +708,8 @@ def _():
'rankInfo': rankInfo,
'games': games,
'triggerByUser': True,
'isPublic': summoner.isPublic
'isPublic': summoner.isPublic,
'tagLine': summoner.tagLine
}
if champions:
emitInfo["champions"] = champions
Expand Down Expand Up @@ -766,18 +772,20 @@ def _():
champions = getRecentChampions(games['games'])

self.careerInterface.careerInfoChanged.emit(
{'name': summoner.completeName,
'icon': icon,
'level': level,
'xpSinceLastLevel': xpSinceLastLevel,
'xpUntilNextLevel': xpUntilNextLevel,
'puuid': summoner.puuid,
'rankInfo': rankInfo,
'games': games,
'champions': champions,
'triggerByUser': True,
'isPublic': summoner.isPublic
}
{
'name': summoner.name,
'icon': icon,
'level': level,
'xpSinceLastLevel': xpSinceLastLevel,
'xpUntilNextLevel': xpUntilNextLevel,
'puuid': summoner.puuid,
'rankInfo': rankInfo,
'games': games,
'champions': champions,
'triggerByUser': True,
'isPublic': summoner.isPublic,
'tagline': summoner.tagLine
}
)
self.careerInterface.hideLoadingPage.emit()

Expand Down Expand Up @@ -844,18 +852,20 @@ def _():
champions = getRecentChampions(games['games'])

self.careerInterface.careerInfoChanged.emit(
{'name': summoner.completeName,
'icon': icon,
'level': level,
'xpSinceLastLevel': xpSinceLastLevel,
'xpUntilNextLevel': xpUntilNextLevel,
'puuid': summoner.puuid,
'rankInfo': rankInfo,
'games': games,
'champions': champions,
'triggerByUser': True,
'isPublic': summoner.isPublic
}
{
'name': summoner.name,
'icon': icon,
'level': level,
'xpSinceLastLevel': xpSinceLastLevel,
'xpUntilNextLevel': xpUntilNextLevel,
'puuid': summoner.puuid,
'rankInfo': rankInfo,
'games': games,
'champions': champions,
'triggerByUser': True,
'isPublic': summoner.isPublic,
'tagLine': summoner.tagLine
}
)
self.careerInterface.hideLoadingPage.emit()

Expand Down

0 comments on commit 1e9c2d0

Please sign in to comment.