2021-03-25 23:49:05 +13:00
|
|
|
from logging import getLogger
|
|
|
|
|
2021-09-09 05:43:49 +12:00
|
|
|
from PyQt5.QtCore import pyqtSignal, Qt
|
2022-06-20 21:44:57 +12:00
|
|
|
from PyQt5.QtWidgets import QFrame, QAction
|
2022-01-07 12:29:29 +13:00
|
|
|
from legendary.models.game import Game
|
2022-06-19 06:45:36 +12:00
|
|
|
|
|
|
|
from rare.shared.image_manager import ImageManagerSingleton, ImageSize
|
2022-06-20 05:42:49 +12:00
|
|
|
from rare.widgets.image_widget import ImageWidget
|
2021-03-25 23:49:05 +13:00
|
|
|
|
|
|
|
logger = getLogger("Uninstalled")
|
|
|
|
|
|
|
|
|
2022-06-20 21:44:57 +12:00
|
|
|
class BaseUninstalledWidget(QFrame):
|
2021-09-14 08:27:37 +12:00
|
|
|
show_uninstalled_info = pyqtSignal(Game)
|
2021-03-25 23:49:05 +13:00
|
|
|
|
|
|
|
def __init__(self, game, core, pixmap):
|
|
|
|
super(BaseUninstalledWidget, self).__init__()
|
2022-06-19 06:45:36 +12:00
|
|
|
self.image_manager = ImageManagerSingleton()
|
|
|
|
|
2021-03-25 23:49:05 +13:00
|
|
|
self.game = game
|
2022-01-07 12:29:29 +13:00
|
|
|
if self.game.app_title == "Unreal Engine":
|
|
|
|
self.game.app_title = f"{self.game.app_title} {self.game.app_name.split('_')[-1]}"
|
|
|
|
|
2021-03-25 23:49:05 +13:00
|
|
|
self.core = core
|
2022-06-20 05:42:49 +12:00
|
|
|
self.image = ImageWidget(self)
|
|
|
|
self.image.setFixedSize(ImageSize.Display)
|
|
|
|
self.image.setPixmap(pixmap)
|
2021-04-08 04:17:56 +12:00
|
|
|
self.installing = False
|
2021-09-09 05:43:49 +12:00
|
|
|
self.setContextMenuPolicy(Qt.ActionsContextMenu)
|
2021-03-27 01:29:26 +13:00
|
|
|
|
2021-09-09 05:43:49 +12:00
|
|
|
reload_image = QAction(self.tr("Reload Image"), self)
|
|
|
|
reload_image.triggered.connect(self.reload_image)
|
|
|
|
self.addAction(reload_image)
|
|
|
|
|
|
|
|
def reload_image(self):
|
2022-06-19 06:45:36 +12:00
|
|
|
self.image_manager.download_image_blocking(self.game, force=True)
|
|
|
|
pm = self.image_manager.get_pixmap(self.game.app_name, color=False)
|
2022-06-20 05:42:49 +12:00
|
|
|
self.image.setPixmap(pm)
|
2021-09-09 05:43:49 +12:00
|
|
|
|
2021-03-25 23:49:05 +13:00
|
|
|
def install(self):
|
2021-09-14 08:27:37 +12:00
|
|
|
self.show_uninstalled_info.emit(self.game)
|