1
0
Fork 0
mirror of synced 2024-06-29 19:51:02 +12:00
Rare/rare/components/tabs/games/game_widgets/icon_game_widget.py
loathingKernel dfa12a0138
IconGameWidget: Make icons slightly smaller by using the Library preset
Previously the Display and Library presets were equal. Make the
icons smaller by making the Library preset ~75% of the Display.preset
2023-12-14 13:57:22 +02:00

46 lines
1.4 KiB
Python

from logging import getLogger
from typing import Optional
from PyQt5.QtCore import QEvent
from rare.models.game import RareGame
from rare.models.image import ImageSize
from .game_widget import GameWidget
from .icon_widget import IconWidget
logger = getLogger("IconGameWidget")
class IconGameWidget(GameWidget):
def __init__(self, rgame: RareGame, parent=None):
super().__init__(rgame, parent)
self.setObjectName(f"{rgame.app_name}")
self.setFixedSize(ImageSize.Library)
self.ui = IconWidget()
self.ui.setupUi(self)
self.ui.title_label.setText(self.rgame.app_title)
self.ui.launch_btn.clicked.connect(self._launch)
self.ui.launch_btn.setVisible(self.rgame.is_installed)
self.ui.install_btn.clicked.connect(self._install)
self.ui.install_btn.setVisible(not self.rgame.is_installed)
self.ui.launch_btn.setEnabled(self.rgame.can_launch)
self.update_state()
# 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)
def enterEvent(self, a0: Optional[QEvent] = None) -> None:
if a0 is not None:
a0.accept()
self.ui.enterAnimation(self)
def leaveEvent(self, a0: Optional[QEvent] = None) -> None:
if a0 is not None:
a0.accept()
self.ui.leaveAnimation(self)