4063195b4d
When updates are queued, they are removed from the update's list. An exceptions is made when the queued item comes from repairing (without updating), in which case the update is disabled for the runtime. A queued item can be either removed (if it is an update it will be added back to the updates groups) or forced to be updated now. If a queued item is forced, the currently running item will be added to the front of the queue. Downloads will be queued if there is no active download but there is a queue already. The download thread is now responsible for emitting the progress to `RareGame` InstallDialog: Pass `RareGame` and `InstallOptionsModel` only as arguments. The `update`, `repair` and `silent` arguments are already part of `InstallOptionsModel` `RareGame` is used to query information about the game. InstallInfoWorker: Pass only `InstallOptionsModel` as argument Emit `InstallQueueItemModel` as result, to re-use the worker when queuing stopped games RareGame: Query and store metadata property about entitlement grant date RareGame: Add `RareEosOverlay` class that imitates `RareGame` to handle the overlay LibraryWidgetController: Remove dead signal routing code, these signals are handled by `RareGame` Directly parent library widgets instead of reparenting them GameWidgets: Remove unused signals EOSGroup: Set install location based on preferences and use EOSOverlayApp from legendary GamesTab: Connect the `progress` signals of dlcs to the base game's signals GamesTab: Remove dead code GlobalSignals: Remove `ProgresSignals` RareCore: Mangle internal signleton's names Signed-off-by: loathingKernel <142770+loathingKernel@users.noreply.github.com>
78 lines
2.7 KiB
Python
78 lines
2.7 KiB
Python
from logging import getLogger
|
|
from typing import List
|
|
|
|
from PyQt5.QtCore import pyqtSignal, pyqtSlot
|
|
from PyQt5.QtGui import QIcon
|
|
from PyQt5.QtWidgets import QSystemTrayIcon, QMenu, QAction, QApplication
|
|
|
|
from rare.shared import RareCore, LegendaryCoreSingleton, GlobalSignalsSingleton
|
|
|
|
logger = getLogger("TrayIcon")
|
|
|
|
|
|
class TrayIcon(QSystemTrayIcon):
|
|
# none:
|
|
show_app: pyqtSignal = pyqtSignal()
|
|
# int: exit code
|
|
exit_app: pyqtSignal = pyqtSignal(int)
|
|
|
|
def __init__(self, parent=None):
|
|
super(TrayIcon, self).__init__(parent=parent)
|
|
self.__parent = parent
|
|
self.rcore = RareCore.instance()
|
|
self.core = LegendaryCoreSingleton()
|
|
|
|
self.setIcon(QIcon(":/images/Rare.png"))
|
|
self.setVisible(True)
|
|
self.setToolTip(QApplication.applicationName())
|
|
|
|
self.menu = QMenu()
|
|
|
|
self.show_action = QAction(QApplication.applicationName())
|
|
self.show_action.triggered.connect(self.show_app)
|
|
self.menu.addAction(self.show_action)
|
|
|
|
self.menu.addSeparator()
|
|
self.text_action = QAction("Quick launch")
|
|
self.text_action.setEnabled(False)
|
|
self.menu.addAction(self.text_action)
|
|
|
|
# We need to reference this separator to add game actions before it
|
|
self.separator = self.menu.addSeparator()
|
|
self.exit_action = QAction(self.tr("Quit"))
|
|
self.exit_action.triggered.connect(lambda: self.exit_app.emit(0))
|
|
self.menu.addAction(self.exit_action)
|
|
|
|
self.game_actions: List[QAction] = []
|
|
self.update_actions()
|
|
|
|
self.setContextMenu(self.menu)
|
|
|
|
self.signals = GlobalSignalsSingleton()
|
|
self.signals.game.uninstalled.connect(self.remove_button)
|
|
self.signals.application.update_tray.connect(self.update_actions)
|
|
|
|
def last_played(self) -> List:
|
|
last_played = [game for game in self.rcore.games if (game.metadata and game.is_installed)]
|
|
last_played.sort(key=lambda g: g.metadata.last_played, reverse=True)
|
|
return last_played[0:5]
|
|
|
|
@pyqtSlot()
|
|
def update_actions(self):
|
|
for action in self.game_actions:
|
|
action.deleteLater()
|
|
self.game_actions.clear()
|
|
for rgame in self.last_played():
|
|
a = QAction(rgame.app_title)
|
|
a.setProperty("app_name", rgame.app_name)
|
|
a.triggered.connect(
|
|
lambda: self.rcore.get_game(self.sender().property("app_name")).launch()
|
|
)
|
|
self.menu.insertAction(self.separator, a)
|
|
self.game_actions.append(a)
|
|
|
|
@pyqtSlot(str)
|
|
def remove_button(self, app_name: str):
|
|
if action := next((i for i in self.game_actions if i.property("app_name") == app_name), None):
|
|
self.game_actions.remove(action)
|
|
action.deleteLater()
|