Update to v0.1.4

Add `is_function_in_file` and if the key is "<ORIGINAL>", the `TranslationManager.translate()` will return it directly. (For some strings that don't need to translate in specific language)

Launcher
Update to 0.1.0a0

Add plugin system support and add some useful apis for plugin.
Add "Refresh avatar cache" to account page.
This commit is contained in:
wei committed 2026-10-30 00:16:04 +08:00
1 parent deb06f0190
commit c3662d4cc6
34 files changed
+2192 -57

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
__version__ = '0.1.3'
__version__ = '0.1.4'
__description__ = """
The core library of the *Launcher*
+22
View File
@@ -0,0 +1,22 @@
import ast
def is_function_in_file(file_path, function_name) -> tuple[bool, bool]:
"""
Parse a Python file via ast module to check if a function exists.
:param file_path:
:param function_name:
:return:
is_check_success: bool
is_function_exist: bool
"""
try:
with open(file_path, "r", encoding="utf-8") as f:
root = ast.parse(f.read(), filename=file_path)
for node in ast.iter_child_nodes(root):
if isinstance(node, ast.FunctionDef) and node.name == function_name:
return True, True
return True, False
except (FileNotFoundError, SyntaxError):
return False, False
+1 -1
View File
@@ -1,5 +1,5 @@
"""
Contains some function that deal with 3rd party api
Contains some functions that dealing with 3rd party api
"""
import requests
+4
View File
@@ -54,5 +54,9 @@ class TranslationManager(QObject):
def translate(self, key: str, /, **values: Any) -> str:
text = self._catalog.get(key, key)
if text == "<ORIGINAL>":
return key
return text.format(**values) if values else text
+26
View File
@@ -0,0 +1,26 @@
from PySide6.QtWidgets import QLabel, QPushButton
class ItemButton(QPushButton):
"""Expose button states on child labels for reliable QSS color rules."""
def __init__(self, parent=None):
super().__init__(parent)
self.toggled.connect(
lambda checked: self._set_label_state("itemChecked", checked)
)
def _set_label_state(self, name: str, active: bool) -> None:
for label in self.findChildren(QLabel):
label.setProperty(name, active)
label.style().unpolish(label)
label.style().polish(label)
label.update()
def enterEvent(self, event):
super().enterEvent(event)
self._set_label_state("itemHovered", True)
def leaveEvent(self, event):
super().leaveEvent(event)
self._set_label_state("itemHovered", False)