Skip to content

Commit

Permalink
修复了设置生涯背景时每次选择皮肤都会从第一页开始的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Nov 14, 2024
1 parent d5736e6 commit ff8f56b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
25 changes: 19 additions & 6 deletions app/components/multi_champion_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ def __init__(self, champions: dict, parent=None):
class SplashesSelectWidget(QWidget):
selectedChanged = pyqtSignal(int, str)

def __init__(self, skinList, parent=None):
def __init__(self, skinList, skinId, parent=None):
super().__init__(parent)

self.skinList = skinList
self.skinId = skinId

self.vBoxLayout = QVBoxLayout(self)

self.viewWidget = QWidget()
Expand All @@ -227,8 +230,6 @@ def __init__(self, skinList, parent=None):
self.buttonsGroup = QWidget()
self.buttonsLayout = QVBoxLayout()

self.skinList = skinList

self.splashesImg = TopRoundedLabel(radius=8.0, parent=self)
self.splashesNameLabel = QLabel()
self.pager = HorizontalPipsPager()
Expand Down Expand Up @@ -266,11 +267,23 @@ def __initWidget(self):
self.pager.setNextButtonDisplayMode(PipsScrollButtonDisplayMode.ALWAYS)
self.pager.setPageNumber(len(self.skinList))
self.pager.currentIndexChanged.connect(self.__onChangeSplashes)
self.pager.setCurrentIndex(0)
self.__initPagerIndex()

self.buttonsGroup.setObjectName("buttonsGroup")
self.viewWidget.setObjectName("viewWidget")

def __initPagerIndex(self):
if not self.skinId:
self.pager.setCurrentIndex(0)
return

for i, item in enumerate(self.skinList):
if item[1]['skinId'] == self.skinId:
self.pager.setCurrentIndex(i)
return

self.pager.setCurrentIndex(0)

@asyncSlot(int)
async def __onChangeSplashes(self, idx):
skinItem = self.skinList[idx]
Expand All @@ -284,11 +297,11 @@ async def __onChangeSplashes(self, idx):

class SplashesFlyout(FlyoutViewBase):

def __init__(self, champions: dict, parent=None):
def __init__(self, champions: dict, skinId, parent=None):
super().__init__(parent)

self.vBoxLayout = QVBoxLayout(self)
self.vBoxLayout.setContentsMargins(0, 0, 0, 0)
self.skinWidget = SplashesSelectWidget(champions)
self.skinWidget = SplashesSelectWidget(champions, skinId)

self.vBoxLayout.addWidget(self.skinWidget)
7 changes: 4 additions & 3 deletions app/view/auxiliary_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,15 @@ def __initWidget(self):

def __onSelectButtonClicked(self):
view = ChampionSelectFlyout(self.champions)
view.championSelected.connect(self.__onChampionSelected)

self.w = Flyout.make(view, self.championButton,
self, FlyoutAnimationType.SLIDE_RIGHT, True)

view.championSelected.connect(self.__onChampionSelected)

def __onSkinButtonClicked(self):
view = SplashesFlyout(self.skins)
view = SplashesFlyout(self.skins, self.chosenSkinId)
view.skinWidget.selectedChanged.connect(self.__onSkinSelectedChanged)

Flyout.make(view, self.skinButton, self,
FlyoutAnimationType.SLIDE_RIGHT, True)

Expand Down

0 comments on commit ff8f56b

Please sign in to comment.