Skip to content

Commit

Permalink
Merge pull request #375 from jqyisbest/main
Browse files Browse the repository at this point in the history
修复艾欧尼亚对局信息不包含编号导致从对局信息跳转历史战绩时查询失败的问题
  • Loading branch information
Zzaphkiel authored May 17, 2024
2 parents a461ba7 + c37a273 commit 5e337e4
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions app/view/game_info_interface.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import copy
from typing import Dict

from PyQt5.QtCore import pyqtSignal, Qt, QPropertyAnimation, QRect
from PyQt5.QtCore import pyqtSignal, Qt, QPropertyAnimation, QRect, QTimer
from PyQt5.QtWidgets import (QHBoxLayout, QLabel, QFrame, QVBoxLayout,
QSpacerItem, QSizePolicy, QStackedWidget,
QGridLayout, QSplitter, QApplication, QWidget)
from PyQt5.QtGui import QPixmap, QFont, QPainter, QColor, QPalette, QImage, QFontMetrics
from qasync import asyncSlot

from ..common.qfluentwidgets import (SmoothScrollArea, TransparentTogglePushButton,
ToolTipFilter, ToolTipPosition, setCustomStyleSheet)
Expand Down Expand Up @@ -521,7 +522,6 @@ def updateSummoners(self, summoners):
for i, summoner in enumerate(summoners):
if not summoner:
continue

games = Games(summoner)
self.items[summoner["summonerId"]] = games

Expand Down Expand Up @@ -558,6 +558,8 @@ def __init__(self, summoner, parent=None):

self.gamesLayout = QVBoxLayout()

self.qtimerSummonerNameClick = QTimer()

# self.setSizePolicy(QSizePolicy.Policy.Expanding,
# QSizePolicy.Policy.Fixed)

Expand All @@ -566,12 +568,13 @@ def __init__(self, summoner, parent=None):
nameColor = None
if fateFlag:
nameColor = "#bf242a" if fateFlag == "enemy" else "#057748"
self.summonerPuuid = summoner['puuid']
self.summonerName = SummonerName(
name, isPublic=summoner["isPublic"], color=nameColor, tagLine=summoner['tagLine'], tips=summoner["recentlyChampionName"])
name, isPublic=summoner["isPublic"], color=nameColor, tagLine=summoner['tagLine'],
tips=summoner["recentlyChampionName"])
self.summonerName.setObjectName("summonerName")

self.summonerName.clicked.connect(
lambda: signalBus.toSearchInterface.emit(self.summonerName.text()))
self.summonerName.clicked.connect(self.__onSummonerNameClicked)

self.summonerName.setFixedHeight(60)

Expand All @@ -592,6 +595,26 @@ def __init__(self, summoner, parent=None):
self.gamesLayout.addStretch(11-len(games))
self.gamesLayout.addSpacing(5)

@asyncSlot()
async def __onSummonerNameClicked(self):
if not self.qtimerSummonerNameClick.isActive(): # 防止短时间内多次点击
self.summonerName.setDisabled(True)
tagLine = self.summonerName.tagLine
if tagLine is None or len(str(tagLine).strip()) == 0:
# 现在全区都有编号了 万一对局信息中没包含编号 走别的接口单独查一次
if self.summonerPuuid and len(str(self.summonerPuuid).strip()) != 0:
summonerForTagLine = await connector.getSummonerByPuuid(self.summonerPuuid)
if summonerForTagLine['tagLine'] and len(str(summonerForTagLine['tagLine'])) != 0:
self.summonerName.tagLine = summonerForTagLine['tagLine']
else:
self.summonerName.setEnabled(True)
return
else:
self.summonerName.setEnabled(True)
return
self.qtimerSummonerNameClick.singleShot(1000, lambda: self.summonerName.setEnabled(True))
signalBus.toSearchInterface.emit(self.summonerName.text())


class GameTab(ColorAnimationFrame):

Expand Down

0 comments on commit 5e337e4

Please sign in to comment.