Skip to content

Commit

Permalink
Merge pull request #520 from loathingKernel/develop
Browse files Browse the repository at this point in the history
UI: simplify Epic Overlay Services group layout and compine Wine/Proton groups under compatibility
  • Loading branch information
loathingKernel authored Jan 15, 2025
2 parents dd7fb0d + 4b54e58 commit b33d456
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 286 deletions.
1 change: 1 addition & 0 deletions rare/components/tabs/library/details/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, parent=None):
self.ui = Ui_GameDetails()
self.ui.setupUi(self)
# lk: set object names for CSS properties
self.ui.install_path.setObjectName("LinkLabel")
self.ui.install_button.setObjectName("InstallButton")
self.ui.modify_button.setObjectName("InstallButton")
self.ui.uninstall_button.setObjectName("UninstallButton")
Expand Down
80 changes: 40 additions & 40 deletions rare/components/tabs/library/integrations/eos_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ def __init__(self, overlay: RareEosOverlay, prefix: Optional[str], parent=None):
prefix.replace(os.path.expanduser("~"), "~") if prefix is not None else overlay.app_title,
parent=self,
)
self.prefix_label.setAlignment(Qt.AlignmentFlag.AlignLeft|Qt.AlignmentFlag.AlignVCenter)

self.overlay_label = ElideLabel(parent=self)
self.overlay_label.setDisabled(True)
self.overlay_label.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignVCenter)

self.path_select = QComboBox(self)
self.path_select.setMaximumWidth(150)
Expand All @@ -68,11 +71,11 @@ def __init__(self, overlay: RareEosOverlay, prefix: Optional[str], parent=None):

layout = QHBoxLayout(self)
layout.setContentsMargins(-1, 0, 0, 0)
layout.addWidget(self.indicator)
layout.addWidget(self.indicator, alignment=Qt.AlignmentFlag.AlignLeft)
layout.addWidget(self.prefix_label, stretch=2)
layout.addWidget(self.overlay_label, stretch=3)
layout.addWidget(self.path_select)
layout.addWidget(self.button)
layout.addWidget(self.overlay_label, stretch=1)
layout.addWidget(self.path_select, alignment=Qt.AlignmentFlag.AlignRight)
layout.addWidget(self.button, alignment=Qt.AlignmentFlag.AlignRight)

self.overlay = overlay
self.prefix = prefix
Expand All @@ -98,12 +101,15 @@ 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.setVisible(bool(active_path))
self.path_select.clear()

if not self.overlay.is_installed and not self.overlay.available_paths(self.prefix):
self.setDisabled(True)
self.indicator.setPixmap(qta_icon("fa.circle-o", color="grey").pixmap(20, 20))
self.overlay_label.setText(self.overlay.active_path(self.prefix))
active_path = self.overlay.active_path(self.prefix)
self.overlay_label.setText(f"<i>{active_path}</i>")
self.overlay_label.setVisible(bool(active_path))
self.button.setText(self.tr("Unavailable"))
return

Expand Down Expand Up @@ -168,18 +174,19 @@ def __init__(self, parent=None):
self.ui.install_button.setObjectName("InstallButton")
self.ui.uninstall_button.setObjectName("UninstallButton")

self.ui.install_page_layout.setAlignment(Qt.AlignmentFlag.AlignTop)
self.ui.info_page_layout.setAlignment(Qt.AlignmentFlag.AlignTop)
self.ui.install_page_layout.setAlignment(Qt.AlignmentFlag.AlignBottom)
self.ui.update_page_layout.setAlignment(Qt.AlignmentFlag.AlignBottom)

self.ui.install_button.setIcon(qta_icon("ri.install-line"))
self.ui.uninstall_button.setIcon(qta_icon("ri.uninstall-line"))

self.installed_path_label = ElideLabel(parent=self)
self.installed_path_label.setOpenExternalLinks(True)
self.installed_version_label = ElideLabel(parent=self)
self.version = ElideLabel(parent=self)
self.install_path = QLabel(parent=self)
self.install_path.setObjectName("LinkLabel")
self.install_path.setOpenExternalLinks(True)

self.ui.info_label_layout.setWidget(0, QFormLayout.ItemRole.FieldRole, self.installed_version_label)
self.ui.info_label_layout.setWidget(1, QFormLayout.ItemRole.FieldRole, self.installed_path_label)
self.ui.info_layout.setWidget(0, QFormLayout.ItemRole.FieldRole, self.version)
self.ui.info_layout.setWidget(1, QFormLayout.ItemRole.FieldRole, self.install_path)

self.rcore = RareCore.instance()
self.core = self.rcore.core()
Expand All @@ -194,31 +201,31 @@ def __init__(self, parent=None):
self.ui.update_button.clicked.connect(self.install_overlay)
self.ui.uninstall_button.clicked.connect(self.uninstall_overlay)

if self.overlay.is_installed: # installed
self.installed_version_label.setText(f"<b>{self.overlay.version}</b>")
self.installed_path_label.setText(
style_hyperlink(
QUrl.fromLocalFile(self.overlay.install_path).toString(), self.overlay.install_path
)
)
self.ui.overlay_stack.setCurrentWidget(self.ui.info_page)
else:
self.ui.overlay_stack.setCurrentWidget(self.ui.install_page)
self.ui.update_button.setEnabled(False)

self.threadpool = QThreadPool.globalInstance()
self.worker: Optional[CheckForUpdateWorker] = None

def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous():
return super().showEvent(a0)
self.check_for_update()
self.update_prefixes()
self.update_state()
self.update_prefixes()
self.check_for_update()
super().showEvent(a0)

@Slot()
def update_state(self):
if self.overlay.is_installed: # installed
self.version.setText(f"<b>{self.overlay.version}</b>")
self.ui.button_stack.setCurrentWidget(self.ui.update_page)
else:
self.version.setText(self.tr("<b>Epic Online Services Overlay is not installed</b>"))
self.ui.button_stack.setCurrentWidget(self.ui.install_page)
self.install_path.setEnabled(self.overlay.is_installed)
self.install_path.setText(
style_hyperlink(QUrl.fromLocalFile(self.overlay.install_path).toString(), self.overlay.install_path)
if self.overlay.is_installed else "N/A"
)

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)
Expand All @@ -244,7 +251,7 @@ def update_prefixes(self):
@Slot(bool)
def check_for_update_finished(self, update_available: bool):
self.worker = None
self.ui.update_button.setEnabled(update_available)
self.ui.update_button.setEnabled(self.overlay.state == RareEosOverlay.State.IDLE and update_available)

def check_for_update(self):
self.ui.update_button.setEnabled(False)
Expand All @@ -261,29 +268,22 @@ def check_for_update(self):
@Slot()
def install_finished(self):
if not self.overlay.is_installed:
logger.error("Something went wrong while installing overlay")
QMessageBox.warning(self, "Error", self.tr("Something went wrong while installing Overlay"))
logger.error("Something went wrong while installing EOS Overlay")
QMessageBox.warning(self, "Error", self.tr("Something went wrong while installing EOS Overlay"))
return
self.ui.overlay_stack.setCurrentWidget(self.ui.info_page)
self.installed_version_label.setText(f"<b>{self.overlay.version}</b>")
self.installed_path_label.setText(
style_hyperlink(
QUrl.fromLocalFile(self.overlay.install_path).toString(), self.overlay.install_path
)
)
self.ui.update_button.setEnabled(False)
self.update_state()

@Slot()
def uninstall_finished(self):
self.ui.overlay_stack.setCurrentWidget(self.ui.install_page)
self.update_state()

@Slot()
def install_overlay(self):
self.overlay.install()

def uninstall_overlay(self):
if not self.overlay.is_installed:
logger.error("No Legendary-managed overlay installation found.")
self.ui.overlay_stack.setCurrentWidget(self.ui.install_page)
logger.error("No Legendary-managed EOS Overlay installation found.")
self.ui.button_stack.setCurrentWidget(self.ui.install_page)
return
self.overlay.uninstall()
2 changes: 1 addition & 1 deletion rare/components/tabs/settings/widgets/env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class EnvVars(QGroupBox):
def __init__(self, parent):
super(EnvVars, self).__init__(parent=parent)
self.setTitle(self.tr("Environment variables"))
self.setTitle(self.tr("Environment"))

self.core = LegendaryCoreSingleton()
self.app_name: str = "default"
Expand Down
45 changes: 35 additions & 10 deletions rare/components/tabs/settings/widgets/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from PySide6.QtGui import QHideEvent
from PySide6.QtWidgets import (
QWidget,
QVBoxLayout
QVBoxLayout,
# QStackedWidget,
QGroupBox,
# QComboBox,
# QFormLayout,
# QLabel,
)

from rare.shared import LegendaryCoreSingleton
Expand Down Expand Up @@ -45,14 +50,36 @@ def __init__(
self.env_vars = envvar_widget(self)

if pf.system() != "Windows":
self.compat = QGroupBox(self.tr("Compatibility"), parent=self)
# self.compat_label = QLabel(self.tr("Runner"))
# self.compat_combo = QComboBox(self)
# self.compat_stack = QStackedWidget(self)

self.compat_layout = QVBoxLayout(self.compat)
# self.compat_layout = QFormLayout(self.compat)
# self.compat_layout.setWidget(0, QFormLayout.ItemRole.LabelRole, self.compat_label)
# self.compat_layout.setWidget(0, QFormLayout.ItemRole.FieldRole, self.compat_combo)
# self.compat_layout.setWidget(1, QFormLayout.ItemRole.SpanningRole, self.compat_stack)
# self.compat_layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.FieldsStayAtSizeHint)
#
self.wine = wine_widget(self)
self.wine.environ_changed.connect(self.env_vars.reset_model)

if pf.system() in {"Linux", "FreeBSD"}:
self.proton_tool = proton_widget(self)
self.proton_tool.environ_changed.connect(self.env_vars.reset_model)
self.proton_tool.tool_enabled.connect(self.wine.tool_enabled)
self.proton_tool.tool_enabled.connect(self.launch.tool_enabled)
self.compat_layout.addWidget(self.wine)
# wine_index = self.compat_stack.addWidget(self.wine)
# self.compat_combo.addItem("Wine", wine_index)

if pf.system() in {"Linux", "FreeBSD"}:
self.proton_tool = proton_widget(self)
self.proton_tool.environ_changed.connect(self.env_vars.reset_model)
self.proton_tool.tool_enabled.connect(self.wine.tool_enabled)
self.proton_tool.tool_enabled.connect(self.launch.tool_enabled)
self.compat_layout.addWidget(self.proton_tool)
# proton_index = self.compat_stack.addWidget(self.proton_tool)
# self.compat_combo.addItem("Proton", proton_index)

# self.compat_combo.currentIndexChanged.connect(
# lambda: self.compat_stack.setCurrentIndex(self.compat_combo.currentData(Qt.ItemDataRole.UserRole))
# )

self.dxvk = dxvk_widget(self)
self.dxvk.environ_changed.connect(self.env_vars.reset_model)
Expand All @@ -64,9 +91,7 @@ def __init__(
self.main_layout = QVBoxLayout(self)
self.main_layout.addWidget(self.launch)
if pf.system() != "Windows":
self.main_layout.addWidget(self.wine)
if pf.system() in {"Linux", "FreeBSD"}:
self.main_layout.addWidget(self.proton_tool)
self.main_layout.addWidget(self.compat)
self.main_layout.addWidget(self.dxvk)
if pf.system() in {"Linux", "FreeBSD"}:
self.main_layout.addWidget(self.mangohud)
Expand Down
2 changes: 1 addition & 1 deletion rare/components/tabs/settings/widgets/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(
parent=None
):
super(LaunchSettingsBase, self).__init__(parent=parent)
self.setTitle(self.tr("Launch settings"))
self.setTitle(self.tr("Launch"))

self.core = LegendaryCoreSingleton()
self.app_name: str = "default"
Expand Down
4 changes: 2 additions & 2 deletions rare/components/tabs/settings/widgets/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def showEvent(self, a0: QShowEvent):
class DxvkSettings(OverlaySettings):
def __init__(self, parent=None):
super(DxvkSettings, self).__init__(parent=parent)
self.setTitle(self.tr("DXVK settings"))
self.setTitle(self.tr("DXVK HUD"))
grid = [
OverlayCheckBox("fps", self.tr("FPS")),
OverlayCheckBox("frametime", self.tr("Frametime")),
Expand Down Expand Up @@ -285,7 +285,7 @@ def update_settings_override(self, state: ActivationStates):
class MangoHudSettings(OverlaySettings):
def __init__(self, parent=None):
super(MangoHudSettings, self).__init__(parent=parent)
self.setTitle(self.tr("MangoHud settings"))
self.setTitle(self.tr("MangoHud"))
grid = [
OverlayCheckBox("read_cfg", self.tr("Read config")),
OverlayCheckBox("fps", self.tr("FPS"), default_enabled=True),
Expand Down
2 changes: 1 addition & 1 deletion rare/components/tabs/settings/widgets/proton.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ProtonSettings(QGroupBox):

def __init__(self, parent=None):
super(ProtonSettings, self).__init__(parent=parent)
self.setTitle(self.tr("Proton settings"))
self.setTitle(self.tr("Proton"))

self.tool_combo = QComboBox(self)
self.tool_combo.currentIndexChanged.connect(self.__on_proton_changed)
Expand Down
5 changes: 3 additions & 2 deletions rare/components/tabs/settings/widgets/wine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from logging import getLogger
from typing import Optional

from PySide6.QtCore import Signal, Qt, QSignalBlocker
from PySide6.QtCore import Signal, Qt, QSignalBlocker, Slot
from PySide6.QtGui import QShowEvent
from PySide6.QtWidgets import QFileDialog, QFormLayout, QGroupBox

Expand All @@ -19,7 +19,7 @@ class WineSettings(QGroupBox):

def __init__(self, parent=None):
super(WineSettings, self).__init__(parent=parent)
self.setTitle(self.tr("Wine settings"))
self.setTitle(self.tr("Wine"))

self.core = LegendaryCoreSingleton()
self.signals = GlobalSignalsSingleton()
Expand Down Expand Up @@ -62,6 +62,7 @@ def showEvent(self, a0: QShowEvent):

return super().showEvent(a0)

@Slot(bool)
def tool_enabled(self, enabled: bool):
if enabled:
config.set_boolean(self.app_name, "no_wine", True)
Expand Down
Loading

0 comments on commit b33d456

Please sign in to comment.