Skip to content

Commit

Permalink
将打开日志作为独立卡片,实现热重启客户端卡片
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed May 8, 2024
1 parent 1d6548b commit b5df9b3
Show file tree
Hide file tree
Showing 9 changed files with 296 additions and 190 deletions.
2 changes: 2 additions & 0 deletions app/common/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Icon(FluentIconBase, Enum):
DUALSCREEN = 'DualScreen'
CIRCLELINE = 'CircleLine'
TEXTCHECK = 'TextCheck'
DOCUMENT = 'Document'
ARROWREPEAT = "ArrowRepeat"

def path(self, theme=Theme.AUTO):
return f'./app/resource/icons/{self.value}_{getIconColor(theme)}.svg'
Binary file modified app/resource/i18n/Seraphine.zh_CN.qm
Binary file not shown.
398 changes: 218 additions & 180 deletions app/resource/i18n/Seraphine.zh_CN.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/resource/icons/ArrowRepeat_black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/resource/icons/ArrowRepeat_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/resource/icons/Document_black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/resource/icons/Document_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 32 additions & 3 deletions app/view/auxiliary_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from ..common.qfluentwidgets import (SettingCardGroup, SwitchSettingCard, ExpandLayout,
SmoothScrollArea, SettingCard, LineEdit, setCustomStyleSheet,
PushButton, ComboBox, SwitchButton, ConfigItem, qconfig,
IndicatorPosition, InfoBar, InfoBarPosition, SpinBox, ExpandGroupSettingCard)
IndicatorPosition, InfoBar, InfoBarPosition, SpinBox,
ExpandGroupSettingCard)

from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QWidget, QLabel, QCompleter, QVBoxLayout, QHBoxLayout, QGridLayout, QLineEdit
Expand Down Expand Up @@ -35,6 +36,8 @@ def __init__(self, parent=None):
self.gameGroup = SettingCardGroup(self.tr("Game"), self.scrollWidget)
self.bpGroup = SettingCardGroup(
self.tr("Ban / Pick"), self.scrollWidget)
self.clientGroup = SettingCardGroup(
self.tr("Client"), self.scrollWidget)

self.onlineStatusCard = OnlineStatusCard(
title=self.tr("Online status"),
Expand Down Expand Up @@ -63,11 +66,17 @@ def __init__(self, parent=None):
self.tr("Lock config"),
self.tr("Make your game config unchangeable"),
cfg.lockConfig, self.gameGroup)

self.fixDpiCard = FixClientDpiCard(
self.tr("Fix client window"),
self.tr(
"Fix incorrect client window size caused by DirectX 9 (need UAC)"),
self.gameGroup
self.clientGroup
)
self.restartClientCard = RestartClientCard(
self.tr("Restart client"),
self.tr("Restart the LOL client without re queuing"),
self.clientGroup
)

self.createPracticeLobbyCard = CreatePracticeLobbyCard(
Expand Down Expand Up @@ -146,12 +155,15 @@ def __initLayout(self):
self.gameGroup.addSettingCard(self.createPracticeLobbyCard)
self.gameGroup.addSettingCard(self.spectateCard)
self.gameGroup.addSettingCard(self.lockConfigCard)
self.gameGroup.addSettingCard(self.fixDpiCard)

self.clientGroup.addSettingCard(self.fixDpiCard)
self.clientGroup.addSettingCard(self.restartClientCard)

self.expandLayout.setSpacing(30)
self.expandLayout.setContentsMargins(36, 0, 36, 0)
self.expandLayout.addWidget(self.bpGroup)
self.expandLayout.addWidget(self.gameGroup)
self.expandLayout.addWidget(self.clientGroup)
self.expandLayout.addWidget(self.profileGroup)


Expand Down Expand Up @@ -637,6 +649,23 @@ async def __onButtonClicked(self):
await fixLCUWindowViaExe()


class RestartClientCard(SettingCard):

def __init__(self, title, content, parent):
super().__init__(Icon.ARROWREPEAT, title, content, parent)
self.pushButton = PushButton(self.tr("Restart"))
self.pushButton.setMinimumWidth(100)

self.hBoxLayout.addWidget(self.pushButton)
self.hBoxLayout.addSpacing(16)

self.pushButton.clicked.connect(self.__onButtonClicked)

@asyncSlot()
async def __onButtonClicked(self):
await connector.restartClient()


class CreatePracticeLobbyCard(ExpandGroupSettingCard):

def __init__(self, title, content, parent):
Expand Down
31 changes: 24 additions & 7 deletions app/view/setting_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ def __init__(self, parent=None):
self.tr('The level of logging for Seraphine (take effect after restart)'),
texts=["Debug", "Info", "Warning", "Error"],
parent=self.generalGroup)
self.viewLogCard = PushSettingCard(
self.tr("Open"), Icon.DOCUMENT, self.tr("Log file"),
self.
tr("Open log directory"),
self.generalGroup)
self.viewLogCard.button.setFixedWidth(100)

# 这玩意左右 padding 大的离谱,手动给它改了
self.viewLogCard.button.setStyleSheet(
"QPushButton {padding-left: 0; padding-right: 0;}")

self.enableStartLolWithApp = SwitchSettingCard(
Icon.CIRCLERIGHT,
Expand All @@ -100,6 +110,11 @@ def __init__(self, parent=None):
self.
tr("Delete all game resources (Apply it when game resources update)"
), self.generalGroup)

self.deleteResourceCard.button.setFixedWidth(100)
self.deleteResourceCard.button.setStyleSheet(
"QPushButton {padding-left: 0; padding-right: 0;}")

self.enableCloseToTray = LooseSwitchSettingCard(
Icon.EXIT,
self.tr("Minimize to tray on close"),
Expand Down Expand Up @@ -172,18 +187,16 @@ def __init__(self, parent=None):
cfg.enableProxy, cfg.proxyAddr, self.updateGroup)

self.aboutGroup = SettingCardGroup(self.tr("About"), self.scrollWidget)

self.feedbackCard = PrimaryPushSettingCard(
self.tr('Provide feedback'), Icon.FEEDBACK,
self.tr('Provide feedback'),
self.tr('Help us improve Seraphine by providing feedback'),
self.aboutGroup)
self.viewLogBtn = PushButton(FluentIcon.LINK, "View Log", self.feedbackCard)
self.viewLogBtn.clicked.connect(lambda: os.system(f'explorer {os.getcwd()}\\log'))
self.feedbackCard.hBoxLayout.removeWidget(self.feedbackCard.button) # Note 它在右边会更协调些, 一会儿加回来
self.feedbackCard.hBoxLayout.addWidget(self.viewLogBtn)
self.feedbackCard.hBoxLayout.addSpacing(16)
self.feedbackCard.hBoxLayout.addWidget(self.feedbackCard.button)
self.feedbackCard.hBoxLayout.addSpacing(16)

# 让它和上面的按钮宽度一样,看起来顺眼点
self.feedbackCard.button.setFixedWidth(100)

self.aboutCard = HyperlinkCard(
GITHUB_URL, self.tr("View GitHub"), Icon.INFO, self.tr('About'),
self.tr('Copyright') + ' © ' + f"{YEAR}, {AUTHOR}. " +
Expand Down Expand Up @@ -227,6 +240,7 @@ def __initLayout(self):
self.generalGroup.addSettingCard(self.enableCloseToTray)
self.generalGroup.addSettingCard(self.gameStartMinimizeCard)
self.generalGroup.addSettingCard(self.logLevelCard)
self.generalGroup.addSettingCard(self.viewLogCard)

self.personalizationGroup.addSettingCard(self.micaCard)
self.personalizationGroup.addSettingCard(self.themeCard)
Expand Down Expand Up @@ -263,6 +277,9 @@ def __connectSignalToSlot(self):
self.feedbackCard.clicked.connect(
lambda: QDesktopServices.openUrl(QUrl(FEEDBACK_URL)))
self.deleteResourceCard.clicked.connect(self.__showFlyout)
self.viewLogCard.clicked.connect(
lambda: os.system(f'explorer {os.getcwd()}\\log')
)

def __onLolFolderCardClicked(self):
folder = QFileDialog.getExistingDirectory(
Expand Down

0 comments on commit b5df9b3

Please sign in to comment.