Skip to content

Commit

Permalink
实现静默启动以及设置项 (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Dec 10, 2024
1 parent d4e257a commit f43a07d
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 151 deletions.
3 changes: 3 additions & 0 deletions app/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ class Config(QConfig):
enableReserveGameinfo = ConfigItem(
"Functions", "EnableReserveGameinfo", False, BoolValidator())

enableSilent = ConfigItem(
"General", "EnableSilent", False, BoolValidator())


YEAR = 2023
AUTHOR = "Zzaphkiel"
Expand Down
1 change: 1 addition & 0 deletions app/common/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Icon(FluentIconBase, Enum):
ERASER = "Eraser"
ATTACHTEXT = "AttachText"
TEXTCOLOR = "TextColor"
SNOOZE = "Snooze"

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.
306 changes: 158 additions & 148 deletions app/resource/i18n/Seraphine.zh_CN.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions app/resource/icons/Snooze_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/Snooze_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import asyncio
from aiohttp.client_exceptions import ClientConnectorError
from qasync import asyncClose, asyncSlot
from PyQt5.QtCore import Qt, pyqtSignal, QSize, QEvent
from PyQt5.QtCore import Qt, pyqtSignal, QSize, QEvent, QTimer
from PyQt5.QtGui import QIcon, QImage
from PyQt5.QtWidgets import QApplication, QSystemTrayIcon

Expand Down Expand Up @@ -101,8 +101,6 @@ def __init__(self):
self.lastTipsTime = time.time()
self.lastTipsType = None

self.isDragging = False

self.__initInterface()
self.__initNavigation()
self.__initListener()
Expand All @@ -115,6 +113,8 @@ def __init__(self):

logger.critical("Seraphine initialized", TAG)

self.__silentStart()

def __initConfig(self):
folder = cfg.get(cfg.lolFolder)

Expand Down Expand Up @@ -278,6 +278,7 @@ def __initWindow(self):
self.move(w // 2 - self.width() // 2, h // 2 - self.height() // 2)

self.show()

QApplication.processEvents()

self.oldHook = sys.excepthook
Expand Down Expand Up @@ -740,6 +741,12 @@ async def closeEvent(self, a0) -> None:
a0.ignore()
self.hide()

def __silentStart(self):
if not cfg.get(cfg.enableSilent):
return

QTimer.singleShot(0, self.hide)

@asyncSlot(str)
async def __switchToSearchInterface(self, name):
self.searchInterface.searchLineEdit.setText(name)
Expand Down
9 changes: 9 additions & 0 deletions app/view/setting_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ def __init__(self, parent=None):
self.lolFolderCard.button.setStyleSheet(
"QPushButton {padding-left: 0; padding-right: 0;}")

self.silentCard = SwitchSettingCard(
Icon.SNOOZE, self.tr("Silently start"),
self.tr(
"Show Seraphine window minimized when it starts"),
cfg.enableSilent
)

self.logGroup = SettingCardGroup(self.tr("Log"), self.scrollWidget)

self.logLevelCard = ComboBoxSettingCard(
Expand Down Expand Up @@ -197,6 +204,7 @@ def __init__(self, parent=None):

self.updateGroup = SettingCardGroup(
self.tr("Update"), self.scrollWidget)

self.checkUpdateCard = SwitchSettingCard(
Icon.UPDATE, self.tr("Check for updates"),
self.tr(
Expand Down Expand Up @@ -261,6 +269,7 @@ def __initLayout(self):
self.generalGroup.addSettingCard(self.enableStartLolWithApp)
self.generalGroup.addSettingCard(self.deleteResourceCard)
self.generalGroup.addSettingCard(self.enableCloseToTray)
self.generalGroup.addSettingCard(self.silentCard)

self.logGroup.addSettingCard(self.logLevelCard)
self.logGroup.addSettingCard(self.viewLogCard)
Expand Down

0 comments on commit f43a07d

Please sign in to comment.