Skip to content

Commit

Permalink
Merge pull request #456 from loathingKernel/develop
Browse files Browse the repository at this point in the history
Minor fixes in steam shortcuts, ubisoft integration and cloud saves
  • Loading branch information
loathingKernel authored Sep 20, 2024
2 parents a24f190 + 3e93625 commit 42086c5
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 39 deletions.
7 changes: 5 additions & 2 deletions rare/commands/launcher/cloud_sync_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ def __init__(self, igame: InstalledGame, dt_local: datetime, dt_remote: datetime
else:
self.status = CloudSyncDialogResult.SKIP

self.sync_ui.date_info_local.setText(dt_local.strftime("%A, %d. %B %Y %X") if dt_local else "None")
self.sync_ui.date_info_remote.setText(dt_remote.strftime("%A, %d. %B %Y %X") if dt_remote else "None")
local_tz = datetime.now().astimezone().tzinfo
self.sync_ui.date_info_local.setText(
dt_local.astimezone(local_tz).strftime("%A, %d %B %Y %X") if dt_local else "None")
self.sync_ui.date_info_remote.setText(
dt_remote.astimezone(local_tz).strftime("%A, %d %B %Y %X") if dt_remote else "None")

self.sync_ui.icon_local.setPixmap(qta_icon("mdi.harddisk", "fa.desktop").pixmap(128, 128))
self.sync_ui.icon_remote.setPixmap(qta_icon("mdi.cloud-outline", "ei.cloud").pixmap(128, 128))
Expand Down
10 changes: 5 additions & 5 deletions rare/components/tabs/library/details/cloud_saves.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import platform
from datetime import datetime
from logging import getLogger
from typing import Tuple

Expand All @@ -23,8 +24,8 @@
from rare.shared.workers.wine_resolver import WineSavePathResolver
from rare.ui.components.tabs.games.game_info.cloud_settings_widget import Ui_CloudSettingsWidget
from rare.ui.components.tabs.games.game_info.cloud_sync_widget import Ui_CloudSyncWidget
from rare.utils.misc import qta_icon
from rare.utils.metrics import timelogger
from rare.utils.misc import qta_icon
from rare.widgets.indicator_edit import PathEdit, IndicatorReasonsCommon
from rare.widgets.loading_widget import LoadingWidget
from rare.widgets.side_tab import SideTabContents
Expand Down Expand Up @@ -188,12 +189,11 @@ def __update_widget(self):

status, (dt_local, dt_remote) = self.rgame.save_game_state

local_tz = datetime.now().astimezone().tzinfo
self.sync_ui.date_info_local.setText(
dt_local.strftime("%A, %d. %B %Y %X") if dt_local and self.rgame.save_path else "None"
)
dt_local.astimezone(local_tz).strftime("%A, %d %B %Y %X") if dt_local else "None")
self.sync_ui.date_info_remote.setText(
dt_remote.strftime("%A, %d. %B %Y %X") if dt_remote and self.rgame.save_path else "None"
)
dt_remote.astimezone(local_tz).strftime("%A, %d %B %Y %X") if dt_remote else "None")

newer = self.tr("Newer")
self.sync_ui.age_label_local.setText(
Expand Down
63 changes: 31 additions & 32 deletions rare/components/tabs/library/integrations/ubisoft_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run_real(self) -> None:

self.signals.worker_finished.emit(redeemed, entitlements, ubi_account_id)
except Exception as e:
logger.error(str(e))
logger.error(e)
self.signals.worker_finished.emit(set(), set(), "error")


Expand Down Expand Up @@ -107,31 +107,31 @@ def __init__(self, game: Game, ubi_account_id, activated: bool = False, parent=N
self.game = game
self.ubi_account_id = ubi_account_id

self.ok_indicator = QLabel(parent=self)
self.ok_indicator.setPixmap(qta_icon("fa.circle-o", color="grey").pixmap(20, 20))
self.ok_indicator.setSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Preferred)
self.redeem_indicator = QLabel(parent=self)
self.redeem_indicator.setPixmap(qta_icon("fa.circle-o", color="grey").pixmap(20, 20))
self.redeem_indicator.setSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Preferred)

self.title_label = ElideLabel(game.app_title, parent=self)

self.link_button = QPushButton(self.tr("Redeem in Ubisoft"), parent=self)
self.link_button.setMinimumWidth(150)
self.link_button.clicked.connect(self.activate)
self.redeem_button = QPushButton(self.tr("Redeem in Ubisoft"), parent=self)
self.redeem_button.setMinimumWidth(150)
self.redeem_button.clicked.connect(self.activate)

if activated:
self.link_button.setText(self.tr("Already activated"))
self.link_button.setDisabled(True)
self.ok_indicator.setPixmap(qta_icon("fa.check-circle-o", color="green").pixmap(QSize(20, 20)))
self.redeem_button.setText(self.tr("Already activated"))
self.redeem_button.setDisabled(True)
self.redeem_indicator.setPixmap(qta_icon("fa.check-circle-o", color="green").pixmap(QSize(20, 20)))

layout = QHBoxLayout(self)
layout.setContentsMargins(-1, 0, 0, 0)
layout.addWidget(self.ok_indicator)
layout.addWidget(self.redeem_indicator)
layout.addWidget(self.title_label, stretch=1)
layout.addWidget(self.link_button)
layout.addWidget(self.redeem_button)

def activate(self):
self.link_button.setDisabled(True)
self.redeem_button.setDisabled(True)
# self.ok_indicator.setPixmap(icon("mdi.loading", color="grey").pixmap(20, 20))
self.ok_indicator.setPixmap(qta_icon("mdi.transit-connection-horizontal", color="grey").pixmap(20, 20))
self.redeem_indicator.setPixmap(qta_icon("mdi.transit-connection-horizontal", color="grey").pixmap(20, 20))

if self.args.debug:
worker = UbiConnectWorker(RareCore.instance().core(), None, None)
Expand All @@ -144,14 +144,14 @@ def activate(self):

def worker_finished(self, error):
if not error:
self.ok_indicator.setPixmap(qta_icon("fa.check-circle-o", color="green").pixmap(QSize(20, 20)))
self.link_button.setDisabled(True)
self.link_button.setText(self.tr("Already activated"))
self.redeem_indicator.setPixmap(qta_icon("fa.check-circle-o", color="green").pixmap(QSize(20, 20)))
self.redeem_button.setDisabled(True)
self.redeem_button.setText(self.tr("Already activated"))
else:
self.ok_indicator.setPixmap(qta_icon("fa.times-circle-o", color="red").pixmap(QSize(20, 20)))
self.ok_indicator.setToolTip(error)
self.link_button.setText(self.tr("Try again"))
self.link_button.setDisabled(False)
self.redeem_indicator.setPixmap(qta_icon("fa.times-circle-o", color="red").pixmap(QSize(20, 20)))
self.redeem_indicator.setToolTip(error)
self.redeem_button.setText(self.tr("Try again"))
self.redeem_button.setDisabled(False)


class UbisoftGroup(QGroupBox):
Expand All @@ -167,19 +167,19 @@ def __init__(self, parent=None):

self.info_label = QLabel(parent=self)
self.info_label.setText(self.tr("Getting information about your redeemable Ubisoft games."))
self.browser_button = QPushButton(self.tr("Link Ubisoft acccount"), parent=self)
self.browser_button.setMinimumWidth(140)
self.browser_button.clicked.connect(
self.link_button = QPushButton(self.tr("Link Ubisoft acccount"), parent=self)
self.link_button.setMinimumWidth(140)
self.link_button.clicked.connect(
lambda: webbrowser.open("https://www.epicgames.com/id/link/ubisoft")
)
self.browser_button.setEnabled(False)
self.link_button.setEnabled(False)

self.loading_widget = LoadingWidget(self)
self.loading_widget.stop()

header_layout = QHBoxLayout()
header_layout.addWidget(self.info_label, stretch=1)
header_layout.addWidget(self.browser_button)
header_layout.addWidget(self.link_button)

layout = QVBoxLayout(self)
layout.addLayout(header_layout)
Expand All @@ -204,21 +204,22 @@ def showEvent(self, a0: QShowEvent) -> None:
@Slot(set, set, str)
def show_ubi_games(self, redeemed: set, entitlements: set, ubi_account_id: str):
self.worker = None
self.loading_widget.stop()
if not redeemed and ubi_account_id != "error":
logger.error(
"No linked ubisoft account found! Link your accounts via your browser and try again."
)
self.info_label.setText(
self.tr("Your account is not linked with Ubisoft. Please link your account and try again.")
)
self.browser_button.setEnabled(True)
self.link_button.setEnabled(True)
elif ubi_account_id == "error":
self.info_label.setText(
self.tr("An error has occurred while requesting your account's Ubisoft information.")
)
self.browser_button.setEnabled(True)
self.link_button.setEnabled(True)
else:
self.browser_button.setEnabled(False)
self.link_button.setEnabled(False)

uplay_games = []
activated = 0
Expand Down Expand Up @@ -257,8 +258,6 @@ def show_ubi_games(self, redeemed: set, entitlements: set, ubi_account_id: str):
)
logger.info(f"Found {len(uplay_games) - activated} game(s) to redeem.")

self.loading_widget.stop()

for game in uplay_games:
widget = UbiLinkWidget(
game, ubi_account_id, activated=game.partner_link_id in redeemed, parent=self
Expand All @@ -273,4 +272,4 @@ def show_ubi_games(self, redeemed: set, entitlements: set, ubi_account_id: str):
parent=self,
)
self.layout().addWidget(widget)
self.browser_button.setEnabled(True)
self.link_button.setEnabled(True)
4 changes: 4 additions & 0 deletions rare/components/tabs/library/widgets/game_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def update_actions(self):
def eventFilter(self, a0: QObject, a1: QEvent) -> bool:
if not isinstance(a1, QEvent):
# FIXME: investigate why this happens
#
# ERROR: Supplied arg1 <class 'PySide6.QtCore.QRunnable'> with target \
# <class 'rare.components.tabs.library.widgets.icon_game_widget.IconGameWidget'> \
# is not a QEvent object
logger.error("Supplied arg1 %s with target %s is not a QEvent object", type(a1), type(a0))
return True
if a0 is self.ui.launch_btn:
Expand Down
2 changes: 2 additions & 0 deletions rare/utils/steam_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def find_steam() -> Optional[str]:
def find_steam_users(steam_path: str) -> List[SteamUser]:
_users = []
vdf_path = os.path.join(steam_path, "config", "loginusers.vdf")
if not os.path.exists(vdf_path):
return _users
with open(vdf_path, 'r') as f:
users = vdf.load(f).get("users", {})
for long_id, user in users.items():
Expand Down

0 comments on commit 42086c5

Please sign in to comment.