Skip to content

Commit

Permalink
Toggle Mark Global button visibility after pressing
Browse files Browse the repository at this point in the history
If the current tool is successfully marked as global,
hide the Mark Global button using the same logic used
to show/hide the button when the CtInfo dialog is opened.

Also move the show/hide logic for the Mark Global button
to `update_game_list_ui` so that it is not
launcher-specific; `is_mark_global_available`
handles the launcher checks for us.
  • Loading branch information
sonic2kk committed Jun 16, 2024
1 parent 24061ce commit 05fb631
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions pupgui2/pupgui2ctinfodialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ def update_game_list(self, cached=True):
self.is_batch_update_available = True
self.ui.btnBatchUpdate.setVisible(not self.ui.searchBox.isVisible())
self.ui.btnBatchUpdate.clicked.connect(self.btn_batch_update_clicked)

if self.is_mark_global_available:
self.ui.btnMarkGlobal.clicked.connect(self.btn_mark_global_clicked)
elif self.install_loc.get('launcher') == 'lutris':
self.update_game_list_lutris()
elif is_heroic_launcher(self.install_loc.get('launcher')):
Expand Down Expand Up @@ -131,6 +128,10 @@ def update_game_list_ui(self):
if self.ctool.is_global:
self.ui.lblGamesList.setText(self.tr('Tool is Global'))

self.ui.btnMarkGlobal.setVisible(self.is_mark_global_available)
if self.is_mark_global_available:
self.ui.btnMarkGlobal.clicked.connect(self.btn_mark_global_clicked)

if len(self.games) < 0 or self.ctool.is_global:
self.ui.btnClose.setFocus()

Expand Down Expand Up @@ -168,5 +169,5 @@ def search_ctinfo_games(self, text):
self.ui.listGames.setRowHidden(row, should_hide)

def btn_mark_global_clicked(self):
set_launcher_global_tool(self.install_loc, self.ctool)
self.is_mark_global_available = not set_launcher_global_tool(self.install_loc, self.ctool)
self.btn_refresh_games_clicked()
10 changes: 7 additions & 3 deletions pupgui2/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def is_mark_global_available(install_loc, ctool: BasicCompatTool) -> bool:
return True # All other checks passed so default to true


def set_launcher_global_tool(install_loc, compat_tool: BasicCompatTool):
def set_launcher_global_tool(install_loc, compat_tool: BasicCompatTool) -> bool:

"""
Set a given compat_tool as global for a given launcher by calling the
Expand All @@ -936,11 +936,15 @@ def set_launcher_global_tool(install_loc, compat_tool: BasicCompatTool):

# Skip empty launcher
if not launcher:
return
return False

if not is_mark_global_available(install_loc, compat_tool):
return
return False

if launcher == 'steam':
steam_config_folder = install_loc.get('vdf_dir', '')
set_steam_global_compat_tool(steam_config_folder, compat_tool)

return True

return False

0 comments on commit 05fb631

Please sign in to comment.