CoreLib
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:
1 parent
deb06f0190
commit
c3662d4cc6
34 files changed
+2192
-57
No files matched your search
+10
-4
@@ -14,7 +14,7 @@ from pathlib import Path
|
||||
import keyring
|
||||
from PySide6.QtCore import QObject, Signal, QThread, QTimer, QSize, Qt, Slot
|
||||
from PySide6.QtGui import QPixmap, QImage
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
from PySide6.QtWidgets import QMessageBox, QWidget
|
||||
from keyring.errors import KeyringError, PasswordDeleteError
|
||||
|
||||
from constant import LAUNCHER_NAME, CLIENT_ID, ACCESS_TOKEN_KEYWORD, REFRESH_TOKEN_KEYWORD, SYSTEM_KEYRING_KEYWORD
|
||||
@@ -366,6 +366,12 @@ class AccountManager(QObject):
|
||||
def _display_name(account: Account) -> str:
|
||||
return account.minecraft_name.strip() or account.username.strip() or "Unnamed Account"
|
||||
|
||||
def register_plugin_apis(self, plugin_manager):
|
||||
plugin_manager.register_api("launcher.accounts.list", self.list_accounts)
|
||||
plugin_manager.register_api("launcher.accounts.contains", self.contains)
|
||||
plugin_manager.register_api("launcher.accounts.current_id", self.get_current_account_id)
|
||||
plugin_manager.register_api("launcher.accounts.set_current", self.set_current_account)
|
||||
|
||||
def list_accounts(self) -> list[AccountSummary]:
|
||||
"""
|
||||
List (Return) all accounts (couple of account summaries)
|
||||
@@ -1437,13 +1443,13 @@ class AccountManager(QObject):
|
||||
# background.
|
||||
return self.app.get_icon(Path(self.app.icon_dir, "head.png")).pixmap(size)
|
||||
|
||||
def request_account_head(self, account_id: str, username: str, size: int = 32) -> bool:
|
||||
"""Download and persist a missing account head without blocking the UI."""
|
||||
def request_account_head(self, account_id: str, username: str, size: int = 32, *, force: bool = False) -> bool:
|
||||
"""Download an account head, optionally replacing a cached avatar."""
|
||||
if account_id in self._head_jobs or not username.strip():
|
||||
return False
|
||||
|
||||
account = self.get_account(account_id)
|
||||
if account is None or self.has_saved_head(account.avatar):
|
||||
if account is None or (not force and self.has_saved_head(account.avatar)):
|
||||
return False
|
||||
|
||||
request_size = min(256, max(32, int(size)))
|
||||
|
||||
Reference in new issue
Block a user