From 0ea4b1a82488a3d755fabebd68afac055547e2a7 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Tue, 19 Dec 2023 20:53:21 +0200 Subject: [PATCH] Dialogs: Re-implement all dialogs on top of a few common super-classes Also add a dialog to select optional downloads before verifying and refactor the move widget into a full-fledged dialog. To keep dialogs in a common format and allow them to share the same properties, three classes of dialogs have been implemented inheriting from each other. The classes are `BaseDialog` -> `ButtonDialog` -> `ActionDialog` * Basedialog: is the basis of all dialogs and is responsible for rejecting close requests from the window manager and the keyboard. It also restricts access to `exec()` and `exec_()` because they are harmful. It serves as the basis of Launch and Login dialogs * ButtonDialog: is offering buttons for accepting or rejecting the presented option. It implements its own buttons and exposes abstract methods to implement handling in them. It restricts access to `close()` because these dialogs should always product a result. It is the basis of Uninstall, Selective dialogs. * ActionDialog: in addition to the ButtonDialog, it offers an action buttom with to validate the form or to make the dialog unable to close. It serves as the basis of Install and Move dialogs. Accordingly all dialogs in Rare have been updated to use these classes. --- rare/components/tabs/games/game_info/cloud_saves.py | 2 +- rare/components/tabs/settings/widgets/launch.py | 2 +- rare/components/tabs/settings/widgets/overlay.py | 2 +- rare/components/tabs/settings/widgets/proton.py | 2 +- rare/components/tabs/settings/widgets/wine.py | 2 +- rare/launcher/console_dialog.py | 1 - 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/rare/components/tabs/games/game_info/cloud_saves.py b/rare/components/tabs/games/game_info/cloud_saves.py index 72241692..8e77f152 100644 --- a/rare/components/tabs/games/game_info/cloud_saves.py +++ b/rare/components/tabs/games/game_info/cloud_saves.py @@ -122,7 +122,7 @@ class CloudSaves(QWidget, SideTabContents): except Exception as e: logger.warning(str(e)) resolver = WineSavePathResolver(self.core, self.rgame) - if not resolver.environment.get("WINEPREFIX"): + if not resolver.environ.get("WINEPREFIX"): del resolver self.cloud_save_path_edit.setText("") QMessageBox.warning(self, "Warning", "No wine prefix selected. Please set it in settings") diff --git a/rare/components/tabs/settings/widgets/launch.py b/rare/components/tabs/settings/widgets/launch.py index 72d3defe..0b0def66 100644 --- a/rare/components/tabs/settings/widgets/launch.py +++ b/rare/components/tabs/settings/widgets/launch.py @@ -46,7 +46,7 @@ class LaunchSettingsBase(QGroupBox): prelaunch_layout.addWidget(self.prelaunch_check) self.main_layout = QFormLayout(self) - self.main_layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow) + self.main_layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) self.main_layout.setLabelAlignment(Qt.AlignRight | Qt.AlignVCenter) self.main_layout.setFormAlignment(Qt.AlignLeading | Qt.AlignTop) diff --git a/rare/components/tabs/settings/widgets/overlay.py b/rare/components/tabs/settings/widgets/overlay.py index eaf2658e..69de4524 100644 --- a/rare/components/tabs/settings/widgets/overlay.py +++ b/rare/components/tabs/settings/widgets/overlay.py @@ -119,7 +119,7 @@ class OverlaySettings(QGroupBox): @abstractmethod def set_activation_state(self, state: ActivationStates): - raise NotImplemented + raise NotImplementedError def update_settings(self): diff --git a/rare/components/tabs/settings/widgets/proton.py b/rare/components/tabs/settings/widgets/proton.py index 1c2baf5e..d013ad91 100644 --- a/rare/components/tabs/settings/widgets/proton.py +++ b/rare/components/tabs/settings/widgets/proton.py @@ -40,7 +40,7 @@ class ProtonSettings(QGroupBox): layout = QFormLayout(self) layout.addRow(self.tr("Proton tool"), self.tool_combo) layout.addRow(self.tr("Compat data"), self.tool_prefix) - layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow) + layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) layout.setLabelAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.setFormAlignment(Qt.AlignLeading | Qt.AlignTop) diff --git a/rare/components/tabs/settings/widgets/wine.py b/rare/components/tabs/settings/widgets/wine.py index c110dfcc..38aad691 100644 --- a/rare/components/tabs/settings/widgets/wine.py +++ b/rare/components/tabs/settings/widgets/wine.py @@ -46,7 +46,7 @@ class WineSettings(QGroupBox): layout = QFormLayout(self) layout.addRow(self.tr("Prefix"), self.wine_prefix) layout.addRow(self.tr("Executable"), self.wine_exec) - layout.setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow) + layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) layout.setLabelAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.setFormAlignment(Qt.AlignLeading | Qt.AlignTop) diff --git a/rare/launcher/console_dialog.py b/rare/launcher/console_dialog.py index 24f45274..bd108ca7 100644 --- a/rare/launcher/console_dialog.py +++ b/rare/launcher/console_dialog.py @@ -1,4 +1,3 @@ -import platform from typing import Union from PyQt5.QtCore import QProcessEnvironment, pyqtSignal, QSize, Qt