2022-12-25 15:21:23 +13:00
|
|
|
from logging import getLogger
|
2023-01-21 13:15:06 +13:00
|
|
|
from typing import Optional
|
2022-12-25 15:21:23 +13:00
|
|
|
|
2023-01-21 13:15:06 +13:00
|
|
|
from PyQt5.QtCore import QEvent, pyqtSlot
|
2022-12-25 15:21:23 +13:00
|
|
|
|
|
|
|
from rare.models.game import RareGame
|
|
|
|
from rare.shared.image_manager import ImageSize
|
|
|
|
from .game_widget import GameWidget
|
|
|
|
from .icon_widget import IconWidget
|
|
|
|
|
|
|
|
logger = getLogger("IconGameWidget")
|
|
|
|
|
|
|
|
|
|
|
|
class IconGameWidget(GameWidget):
|
2023-01-25 02:40:21 +13:00
|
|
|
def __init__(self, rgame: RareGame, parent=None):
|
|
|
|
super(IconGameWidget, self).__init__(rgame, parent)
|
2022-12-25 15:21:23 +13:00
|
|
|
self.setObjectName(f"{rgame.app_name}")
|
|
|
|
self.setFixedSize(ImageSize.Display)
|
|
|
|
self.ui = IconWidget()
|
|
|
|
self.ui.setupUi(self)
|
|
|
|
|
|
|
|
self.ui.title_label.setText(f"<h4>{self.rgame.app_title}</h4>")
|
2023-01-25 02:40:21 +13:00
|
|
|
self.ui.launch_btn.clicked.connect(self._launch)
|
2022-12-25 15:21:23 +13:00
|
|
|
self.ui.launch_btn.setVisible(self.rgame.is_installed)
|
2023-01-25 02:40:21 +13:00
|
|
|
self.ui.install_btn.clicked.connect(self._install)
|
2022-12-25 15:21:23 +13:00
|
|
|
self.ui.install_btn.setVisible(not self.rgame.is_installed)
|
|
|
|
|
|
|
|
self.ui.launch_btn.setEnabled(self.rgame.can_launch)
|
|
|
|
|
2023-01-05 09:32:49 +13:00
|
|
|
self.set_status()
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
def set_status(self):
|
|
|
|
super(IconGameWidget, self).set_status(self.ui.status_label)
|
|
|
|
|
2023-01-25 02:40:21 +13:00
|
|
|
@pyqtSlot()
|
|
|
|
def update_widget(self):
|
|
|
|
super(IconGameWidget, self).update_widget(self.ui.install_btn, self.ui.launch_btn)
|
|
|
|
|
2023-01-21 13:15:06 +13:00
|
|
|
def enterEvent(self, a0: Optional[QEvent] = None) -> None:
|
2022-12-25 15:21:23 +13:00
|
|
|
if a0 is not None:
|
|
|
|
a0.accept()
|
2023-01-05 09:32:49 +13:00
|
|
|
self.ui.tooltip_label.setText(self.enterEventText)
|
2022-12-25 15:21:23 +13:00
|
|
|
self.ui.enterAnimation(self)
|
|
|
|
|
2023-01-21 13:15:06 +13:00
|
|
|
def leaveEvent(self, a0: Optional[QEvent] = None) -> None:
|
2022-12-25 15:21:23 +13:00
|
|
|
if a0 is not None:
|
|
|
|
a0.accept()
|
|
|
|
self.ui.leaveAnimation(self)
|
2023-01-05 09:32:49 +13:00
|
|
|
self.ui.tooltip_label.setText(self.leaveEventText)
|
2022-12-25 15:21:23 +13:00
|
|
|
|
2023-01-25 02:40:21 +13:00
|
|
|
# def sync_finished(self, app_name):
|
|
|
|
# if not app_name == self.rgame.app_name:
|
|
|
|
# return
|
|
|
|
# super().sync_finished(app_name)
|
|
|
|
# self.leaveEvent(None)
|
|
|
|
|
|
|
|
# def game_finished(self, app_name, error):
|
|
|
|
# if app_name != self.rgame.app_name:
|
|
|
|
# return
|
|
|
|
# self.game_running = False
|
|
|
|
# self.leaveEvent(None)
|
|
|
|
#
|
|
|
|
# def game_started(self, app_name):
|
|
|
|
# if app_name == self.rgame.app_name:
|
|
|
|
# self.game_running = True
|
|
|
|
# self.leaveEvent(None)
|