Files
arcaea-offline-pyside-ui/core/singleton.py
283375 c664ed7e8d refactor: moving ui.extends to core
* Settings and Singletons moved
2025-06-04 18:55:23 +08:00

19 lines
374 B
Python

from typing import Generic, TypeVar
from PySide6.QtCore import QObject
T = TypeVar("T")
class Singleton(type, Generic[T]):
_instance = None
def __call__(cls, *args, **kwargs) -> T:
if cls._instance is None:
cls._instance = super().__call__(*args, **kwargs)
return cls._instance
class QSingleton(type(QObject), Singleton):
pass