-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. 重构历史战绩拉取逻辑
- Loading branch information
Showing
3 changed files
with
159 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import sys | ||
|
||
from PyQt5.QtCore import Qt | ||
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QApplication | ||
from qfluentwidgets import CheckBox | ||
from typing import List, Tuple | ||
|
||
|
||
# TODO GameInfoInterface添加筛选功能 | ||
|
||
class ModeFilterWidget(QWidget): | ||
def __init__(self, parent=None): | ||
super().__init__(parent=parent) | ||
|
||
self.selected: List[int] = [] | ||
|
||
self.hBoxLayout = QHBoxLayout(self) | ||
self.hBoxLayout.setAlignment(Qt.AlignCenter) | ||
|
||
# TODO 本地化 | ||
self.rankSoloCheckBox = CheckBox(self.tr("Rank solo")) | ||
self.rankFlexCheckBox = CheckBox(self.tr("Rank Flex")) | ||
self.normalCheckBox = CheckBox(self.tr("Normal")) | ||
self.aramCheckBox = CheckBox(self.tr("Aram")) | ||
|
||
self.checkBoxDict = { | ||
self.rankSoloCheckBox: 420, # 单双排 | ||
self.rankFlexCheckBox: 440, # 灵活组排 | ||
self.normalCheckBox: 430, # 匹配模式 | ||
self.aramCheckBox: 450 # 大乱斗 | ||
} | ||
|
||
for checkBox, num in self.checkBoxDict.items(): | ||
checkBox.stateChanged.connect(lambda state, num=num: self.updateSelected(state, num)) | ||
|
||
self.hBoxLayout.addWidget(self.rankSoloCheckBox, alignment=Qt.AlignCenter) | ||
self.hBoxLayout.addWidget(self.rankFlexCheckBox, alignment=Qt.AlignCenter) | ||
self.hBoxLayout.addWidget(self.normalCheckBox, alignment=Qt.AlignCenter) | ||
self.hBoxLayout.addWidget(self.aramCheckBox, alignment=Qt.AlignCenter) | ||
|
||
self.setLayout(self.hBoxLayout) | ||
|
||
def updateSelected(self, state, num, callback=None): | ||
if state == Qt.Checked: | ||
if num not in self.selected: | ||
self.selected.append(num) | ||
else: | ||
if num in self.selected: | ||
self.selected.remove(num) | ||
|
||
if callback: | ||
callback() | ||
|
||
def setCallback(self, func): | ||
""" | ||
@param func: check box状态改变时回调该方法 | ||
@return: | ||
""" | ||
for checkBox, num in self.checkBoxDict.items(): | ||
checkBox.stateChanged.connect(lambda state, num=num, func=func: self.updateSelected(state, num, func)) | ||
|
||
def getFilterMode(self) -> Tuple[int]: | ||
""" | ||
获取选中的模式 | ||
@return: | ||
@rtype: Tuple[int] | ||
""" | ||
return set(self.selected) | ||
|
||
def setCheckBoxState(self, data: tuple): | ||
""" | ||
设置复选框状态 | ||
@param data: | ||
@return: | ||
""" | ||
for checkBox, num in self.checkBoxDict.items(): | ||
if num in data: | ||
checkBox.setChecked(True) | ||
else: | ||
checkBox.setChecked(False) | ||
|
||
|
||
if __name__ == '__main__': | ||
QApplication.setHighDpiScaleFactorRoundingPolicy( | ||
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) | ||
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) | ||
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) | ||
|
||
app = QApplication(sys.argv) | ||
w = ModeFilterWidget() | ||
w.show() | ||
app.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters