From 6518e606807bb9499e0254bb8361440fd7bc179c Mon Sep 17 00:00:00 2001 From: DavidoTek <54072917+DavidoTek@users.noreply.github.com> Date: Fri, 11 Nov 2022 18:50:06 +0100 Subject: [PATCH] STL: Reference CtInstaller in external methods See https://github.com/DavidoTek/ProtonUp-Qt/pull/125#issuecomment-1311894956 --- .../ctmods/ctmod_steamtinkerlaunch.py | 6 +++--- pupgui2/steamutil.py | 18 +++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pupgui2/resources/ctmods/ctmod_steamtinkerlaunch.py b/pupgui2/resources/ctmods/ctmod_steamtinkerlaunch.py index 0fa5a75a..7bb70e3f 100644 --- a/pupgui2/resources/ctmods/ctmod_steamtinkerlaunch.py +++ b/pupgui2/resources/ctmods/ctmod_steamtinkerlaunch.py @@ -256,7 +256,7 @@ def get_tool(self, version, install_dir, temp_dir): if remove_existing_installation_result.button_clicked == MsgBoxResult.BUTTON_OK: # Remove the Non-ProtonUp-Qt SteamTinkerLaunch if the user checked the box (disabled by defaukt) if remove_existing_installation_result.is_checked: - remove_steamtinkerlaunch(compat_folder=os.path.join(install_dir, 'SteamTinkerLaunch'), remove_config=False) + remove_steamtinkerlaunch(compat_folder=os.path.join(install_dir, 'SteamTinkerLaunch'), remove_config=False, ctmod_object=self) # Nothing more to do here, just continue with the rest of the installation as normal print('User opted to continue installing SteamTinkerLaunch.') @@ -282,7 +282,7 @@ def get_tool(self, version, install_dir, temp_dir): print('Extracting SteamTinkerLaunch...') if os.path.exists(constants.STEAM_STL_INSTALL_PATH): has_existing_install = True # This will also be True for users who installed normally on Steam Deck, but not sure how to differentiate between PUPQT and manual Steam Deck installs - remove_steamtinkerlaunch(remove_config=False) + remove_steamtinkerlaunch(remove_config=False, ctmod_object=self) if not os.path.exists(constants.STEAM_STL_INSTALL_PATH): os.mkdir(constants.STEAM_STL_INSTALL_PATH) @@ -364,7 +364,7 @@ def get_tool(self, version, install_dir, temp_dir): # Cancel installation after shell modification warning print('User asked to cancel installation. Not installing SteamTinkerLaunch...') should_add_path = False # Shouldn't matter since installation will end here, but setting for completeness - remove_steamtinkerlaunch(remove_config=False) # shouldn't need compat_folder arg - (compat_folder=os.path.join(install_dir, 'SteamTinkerLaunch')) + remove_steamtinkerlaunch(remove_config=False, ctmod_object=self) # shouldn't need compat_folder arg - (compat_folder=os.path.join(install_dir, 'SteamTinkerLaunch')) return elif not shellmod_msgbox_result.is_checked and shellmod_msgbox_result.button_clicked == MsgBoxResult.BUTTON_OK: # Continue installation but skip adding to PATH diff --git a/pupgui2/steamutil.py b/pupgui2/steamutil.py index 3e439a6e..c8168cd1 100644 --- a/pupgui2/steamutil.py +++ b/pupgui2/steamutil.py @@ -9,7 +9,7 @@ from .datastructures import SteamApp, AWACYStatus, BasicCompatTool, CTType from .constants import LOCAL_AWACY_GAME_LIST, STEAM_STL_INSTALL_PATH, STEAM_STL_CONFIG_PATH, STEAM_STL_SHELL_FILES, STEAM_STL_FISH_VARIABLES -from PySide6.QtWidgets import QMessageBox +from PySide6.QtWidgets import QMessageBox, QApplication _cached_app_list = [] _cached_steam_ctool_id_map = None @@ -314,7 +314,7 @@ def get_external_steamtinkerlaunch_intall(compat_folder): return os.path.dirname(os.readlink(symlink_path)) if os.path.exists(symlink_path) and not os.readlink(symlink_path) == os.path.join(STEAM_STL_INSTALL_PATH, 'prefix', 'steamtinkerlaunch') else None -def remove_steamtinkerlaunch(compat_folder='', remove_config=True) -> bool: +def remove_steamtinkerlaunch(compat_folder='', remove_config=True, ctmod_object=None) -> bool: """ Removes SteamTinkerLaunch from system by removing the downloaad, removing from path removing config files at `$HOME/.config/steamtinkerlaunch`. @@ -345,11 +345,15 @@ def remove_steamtinkerlaunch(compat_folder='', remove_config=True) -> bool: shutil.rmtree(stl_symlink_path) else: # If we can't remove the actual installation folder, tell the user to remove it themselves and continue with the rest of the uninstallation - # This currently segfaults - mb = QMessageBox() - mb.setWindowTitle('Unable to Remove SteamTinkerLaunch') - mb.setText(f'Access to SteamTinkerLaunch installation folder at \'{stl_symlink_path}\' was denied, please remove this folder manually.\n\nThe uninstallation will continue.') - mb.exec() + mb_title = QApplication.instance().translate('steamutil.py', 'Unable to Remove SteamTinkerLaunch') + mb_text = QApplication.instance().translate('steamutil.py', 'Access to SteamTinkerLaunch installation folder at {STL_SYMLINK_PATH} was denied, please remove this folder manually.\n\nThe uninstallation will continue.').format(STL_SYMLINK_PATH=stl_symlink_path) + if ctmod_object and hasattr(ctmod_object, 'message_box_message'): + ctmod_object.message_box_message.emit(mb_title, mb_text, QMessageBox.Icon.Warning) + else: + mb = QMessageBox() + mb.setWindowTitle(mb_title) + mb.setText(mb_text) + mb.exec() print(f'Error: SteamTinkerLaunch is installed to {stl_symlink_path}, ProtonUp-Qt cannot modify this folder. Folder must be removed manually.') elif os.path.exists(STEAM_STL_INSTALL_PATH):