1
0
Fork 0
mirror of synced 2024-07-03 13:40:47 +12:00
Rare/rare/utils/models.py

86 lines
2.2 KiB
Python
Raw Normal View History

2021-03-09 05:20:28 +13:00
import os
2021-06-20 02:22:30 +12:00
from dataclasses import field, dataclass
from multiprocessing import Queue
2021-03-09 05:20:28 +13:00
2021-09-30 10:22:47 +13:00
from PyQt5.QtCore import QObject, pyqtSignal
from legendary.downloader.mp.manager import DLManager
from legendary.models.downloading import AnalysisResult, ConditionCheckResult
from legendary.models.game import Game, InstalledGame
2021-08-17 08:50:31 +12:00
2021-03-09 05:20:28 +13:00
2021-08-18 01:09:46 +12:00
@dataclass
class InstallOptionsModel:
2021-06-20 02:22:30 +12:00
app_name: str
base_path: str = os.path.expanduser("~/legendary")
max_workers: int = os.cpu_count() * 2
repair: bool = False
no_install: bool = False
ignore_space_req: bool = False
force: bool = False
sdl_list: list = field(default_factory=lambda: [''])
2021-09-30 10:22:47 +13:00
update: bool = False
silent: bool = False
2021-06-20 02:22:30 +12:00
@dataclass
class InstallDownloadModel:
2021-06-20 02:22:30 +12:00
dlmanager: DLManager
analysis: AnalysisResult
game: Game
igame: InstalledGame
repair: bool
repair_file: str
2021-08-18 02:05:00 +12:00
res: ConditionCheckResult
2021-06-20 02:22:30 +12:00
@dataclass
class InstallQueueItemModel:
2021-06-20 02:22:30 +12:00
status_q: Queue = None
download: InstallDownloadModel = None
options: InstallOptionsModel = None
def __bool__(self):
return (self.status_q is not None) and (self.download is not None) and (self.options is not None)
2021-09-30 10:22:47 +13:00
class SignalActions:
quit_app = "quit_app"
dl_status = "dl_status"
install_game = "install_game"
start_installation = "start_installation"
installation_finished = "installation_finished"
uninstall = "uninstall"
set_index = "set_index"
set_dl_tab_text = "set_dl_tab_text"
verification_finished = "verification_finished"
2021-09-30 10:22:47 +13:00
class Signals(QObject):
actions = SignalActions()
tab_widget = pyqtSignal(tuple)
games_tab = pyqtSignal(tuple)
cloud_saves = pyqtSignal(tuple)
dl_tab = pyqtSignal(tuple)
main_window = pyqtSignal(tuple)
app = pyqtSignal(tuple)
2021-10-04 08:29:33 +13:00
@dataclass
class ApiResults:
game_list: list = None
dlcs: list = None
bit32_games: list = None
mac_games: list = None
assets: list = None
no_asset_games: list = None
def __bool__(self):
return self.game_list is not None \
and self.dlcs is not None \
and self.bit32_games is not None \
and self.mac_games is not None \
and self.assets is not None \
and self.no_asset_games is not None