1
0
Fork 0
mirror of synced 2024-05-23 22:10:04 +12:00

EosOverlay: Fix a few remaining issues

* Don't create path when preparing overlay download, it fails on updates.
* Concatenate the overlay install path in InstallDialog instead of passing it as `base_path`
* Respect RareGame state in in the EOS overlay form
This commit is contained in:
loathingKernel 2024-01-19 14:54:09 +02:00
parent 99d0bca5fc
commit 3c01cfc0a8
4 changed files with 52 additions and 27 deletions

View file

@ -1,7 +1,7 @@
from typing import Optional
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QVBoxLayout, QWidget, QLabel, QSpacerItem, QSizePolicy
from PyQt5.QtWidgets import QVBoxLayout, QWidget, QLabel, QSizePolicy
from rare.widgets.side_tab import SideTabWidget
from .egl_sync_group import EGLSyncGroup
@ -34,8 +34,8 @@ class IntegrationsTabs(SideTabWidget):
self.tr(""),
self,
)
self.ubisoft_group = UbisoftGroup(self.eos_ubisoft)
self.eos_group = EosGroup(self.eos_ubisoft)
self.ubisoft_group = UbisoftGroup(self.eos_ubisoft)
self.eos_ubisoft.addWidget(self.eos_group)
self.eos_ubisoft.addWidget(self.ubisoft_group)
self.eos_ubisoft_index = self.addTab(self.eos_ubisoft, self.tr("Epic Overlay and Ubisoft"))

View file

@ -4,6 +4,7 @@ from logging import getLogger
from typing import Optional
from PyQt5.QtCore import QRunnable, QObject, pyqtSignal, QThreadPool, Qt, pyqtSlot, QSize
from PyQt5.QtGui import QShowEvent
from PyQt5.QtWidgets import (
QGroupBox,
QMessageBox,
@ -20,7 +21,7 @@ from rare.lgndr.core import LegendaryCore
from rare.models.game import RareEosOverlay
from rare.shared import RareCore
from rare.ui.components.tabs.games.integrations.eos_widget import Ui_EosWidget
from rare.utils import config_helper
from rare.utils import config_helper as config
from rare.utils.misc import icon
from rare.widgets.elide_label import ElideLabel
@ -51,7 +52,10 @@ class EosPrefixWidget(QFrame):
self.indicator = QLabel(parent=self)
self.indicator.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
self.prefix_label = ElideLabel(prefix if prefix is not None else overlay.app_title, parent=self)
self.prefix_label = ElideLabel(
prefix.replace(os.path.expanduser("~"), "~") if prefix is not None else overlay.app_title,
parent=self,
)
self.overlay_label = ElideLabel(parent=self)
self.overlay_label.setDisabled(True)
@ -93,7 +97,7 @@ class EosPrefixWidget(QFrame):
def update_state(self) -> None:
active_path = os.path.normpath(p) if (p := self.overlay.active_path(self.prefix)) else ""
self.overlay_label.setText(f"<i>{active_path}<\i>")
self.overlay_label.setText(f"<i>{active_path}</i>")
self.path_select.clear()
if not self.overlay.is_installed and not self.overlay.available_paths(self.prefix):
@ -103,8 +107,6 @@ class EosPrefixWidget(QFrame):
self.button.setText(self.tr("Unavailable"))
return
self.setDisabled(False)
if self.overlay.is_enabled(self.prefix):
self.indicator.setPixmap(icon("fa.check-circle-o", color="green").pixmap(QSize(20, 20)))
else:
@ -120,6 +122,8 @@ class EosPrefixWidget(QFrame):
self.path_select.setItemData(self.path_select.findData(path), path, Qt.ToolTipRole)
self.path_select.setCurrentIndex(self.path_select.findData(active_path))
self.setEnabled(self.overlay.state == RareEosOverlay.State.IDLE)
@pyqtSlot()
def action(self) -> None:
path = self.path_select.currentData(Qt.UserRole)
@ -128,10 +132,14 @@ class EosPrefixWidget(QFrame):
if self.overlay.is_enabled(self.prefix) and (path == active_path):
if not self.overlay.disable(prefix=self.prefix):
QMessageBox.warning(
self, "Warning",
self,
"Warning",
self.tr("Failed to completely disable the active EOS Overlay.{}").format(
self.tr(" Since the previous overlay was managed by EGL you can safely ignore this is.")
if active_path != install_path else ""
self.tr(
" Since the previous overlay was managed by EGL you can safely ignore this is."
)
if active_path != install_path
else ""
),
)
else:
@ -141,7 +149,9 @@ class EosPrefixWidget(QFrame):
self,
"Warning",
self.tr("Failed to completely enable EOS overlay.{}").format(
self.tr(" Since the previous overlay was managed by EGL you can safely ignore this is.")
self.tr(
" Since the previous overlay was managed by EGL you can safely ignore this is."
)
if active_path != install_path
else ""
),
@ -175,6 +185,7 @@ class EosGroup(QGroupBox):
self.signals = self.rcore.signals()
self.overlay = self.rcore.get_overlay()
self.overlay.signals.widget.update.connect(self.update_state)
self.overlay.signals.game.installed.connect(self.install_finished)
self.overlay.signals.game.uninstalled.connect(self.uninstall_finished)
@ -191,18 +202,29 @@ class EosGroup(QGroupBox):
self.ui.update_button.setEnabled(False)
self.threadpool = QThreadPool.globalInstance()
self.worker: Optional[CheckForUpdateWorker] = None
def showEvent(self, a0) -> None:
def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous():
return super().showEvent(a0)
self.check_for_update()
self.update_prefixes()
self.update_state()
super().showEvent(a0)
@pyqtSlot()
def update_state(self):
self.ui.install_button.setEnabled(self.overlay.state == RareEosOverlay.State.IDLE)
self.ui.update_button.setEnabled(self.overlay.state == RareEosOverlay.State.IDLE and self.overlay.has_update)
self.ui.uninstall_button.setEnabled(self.overlay.state == RareEosOverlay.State.IDLE)
def update_prefixes(self):
for widget in self.findChildren(EosPrefixWidget, options=Qt.FindDirectChildrenOnly):
widget.deleteLater()
if platform.system() != "Windows":
prefixes = config_helper.get_wine_prefixes()
prefixes = config.get_prefixes()
prefixes = {prefix for prefix in prefixes if config.prefix_exists(prefix)}
if platform.system() == "Darwin":
# TODO: add crossover support
pass
@ -214,16 +236,22 @@ class EosGroup(QGroupBox):
widget = EosPrefixWidget(self.overlay, None)
self.ui.eos_layout.addWidget(widget)
@pyqtSlot(bool)
def check_for_update_finished(self, update_available: bool):
self.worker = None
self.ui.update_button.setEnabled(update_available)
def check_for_update(self):
self.ui.update_button.setEnabled(False)
if not self.overlay.is_installed:
return
def worker_finished(update_available):
self.ui.update_button.setEnabled(update_available)
if self.worker is not None:
return
worker = CheckForUpdateWorker(self.core)
worker.signals.update_available.connect(worker_finished)
QThreadPool.globalInstance().start(worker)
self.worker = CheckForUpdateWorker(self.core)
self.worker.signals.update_available.connect(self.check_for_update_finished)
QThreadPool.globalInstance().start(self.worker)
@pyqtSlot()
def install_finished(self):

View file

@ -575,7 +575,9 @@ class RareEosOverlay(RareGameBase):
@property
def has_update(self) -> bool:
self.core.check_for_overlay_updates()
# lk: Don't check for updates here to ensure fast return
# There is already a thread in the EosGroup form to update it for us asynchronously
# and legendary does it too during login
return self.core.overlay_update_available
def is_enabled(self, prefix: Optional[str] = None) -> bool:
@ -644,13 +646,11 @@ class RareEosOverlay(RareGameBase):
def install(self) -> bool:
if not self.is_idle:
return False
if self.is_installed:
base_path = self.igame.install_path
else:
base_path = self.core.get_default_install_dir()
self.signals.game.install.emit(
InstallOptionsModel(
app_name=self.app_name, base_path=base_path, platform="Windows", overlay=True
app_name=self.app_name,
base_path=self.core.get_default_install_dir(),
platform="Windows", update=self.is_installed, overlay=True
)
)
return True

View file

@ -41,9 +41,6 @@ class InstallInfoWorker(Worker):
else:
raise LgndrException(status.message)
else:
if not os.path.exists(path := self.options.base_path):
os.makedirs(path)
dlm, analysis, igame = self.core.prepare_overlay_install(
path=self.options.base_path
)