mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-17 16:20:18 +00:00
19 lines
374 B
Python
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
|