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-02-08 00:41:59 +13:00
|
|
|
from PyQt5.QtCore import QEvent
|
2022-12-25 15:21:23 +13:00
|
|
|
|
|
|
|
from rare.models.game import RareGame
|
2023-04-17 01:45:36 +12:00
|
|
|
from rare.models.image import ImageSize
|
2022-12-25 15:21:23 +13:00
|
|
|
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):
|
2023-02-08 00:41:59 +13:00
|
|
|
super().__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)
|
|
|
|
|
2023-02-08 00:41:59 +13:00
|
|
|
self.ui.title_label.setText(self.rgame.app_title)
|
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-02-08 00:41:59 +13:00
|
|
|
self.update_state()
|
2023-01-05 09:32:49 +13:00
|
|
|
|
2023-02-08 00:41:59 +13:00
|
|
|
# lk: "connect" the buttons' enter/leave events to this widget
|
|
|
|
self.installEventFilter(self)
|
|
|
|
self.ui.launch_btn.installEventFilter(self)
|
|
|
|
self.ui.install_btn.installEventFilter(self)
|
2023-01-25 02:40:21 +13:00
|
|
|
|
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()
|
|
|
|
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)
|