-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CtInfo: Add Button to Mark Compat Tool as Global #336
base: main
Are you sure you want to change the base?
Changes from all commits
83537b1
6e8cbdf
5236d50
98dc0ec
cbd2318
03cd5c3
b2ded73
5aad7b8
618083e
5b0793a
6fd4d26
9f7c1c2
02fd807
24061ce
05fb631
08849b7
922f9cf
c1fa092
6394f9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
from pupgui2.lutrisutil import get_lutris_game_list, is_lutris_game_using_wine | ||
from pupgui2.pupgui2ctbatchupdatedialog import PupguiCtBatchUpdateDialog | ||
from pupgui2.steamutil import get_steam_game_list | ||
from pupgui2.util import open_webbrowser_thread, get_random_game_name | ||
from pupgui2.util import open_webbrowser_thread, get_random_game_name, is_mark_global_available, set_launcher_global_tool | ||
from pupgui2.heroicutil import get_heroic_game_list, is_heroic_launcher | ||
|
||
from PySide6.QtCore import QObject, Signal, QDataStream, QByteArray | ||
|
@@ -29,6 +29,7 @@ def __init__(self, parent=None, ctool: BasicCompatTool = None, install_loc=None) | |
self.games: List[Union[SteamApp, LutrisGame, HeroicGame]] = [] | ||
self.install_loc = install_loc | ||
self.is_batch_update_available = False | ||
self.is_mark_global_available = False | ||
|
||
self.load_ui() | ||
self.setup_ui() | ||
|
@@ -41,13 +42,14 @@ def load_ui(self): | |
self.ui = loader.load(ui_file.device()) | ||
|
||
def setup_ui(self): | ||
self.update_game_list() | ||
|
||
self.ui.txtToolName.setText(self.ctool.displayname) | ||
self.ui.txtLauncherName.setText(self.install_loc.get('display_name')) | ||
self.ui.txtInstallDirectory.setText(self.ctool.get_install_dir()) | ||
self.ui.btnBatchUpdate.setVisible(False) | ||
self.ui.searchBox.setVisible(False) | ||
|
||
self.update_game_list() | ||
self.ui.btnMarkGlobal.setVisible(self.is_mark_global_available) # Gets updated in update_game_list | ||
|
||
self.ui.btnSearch.clicked.connect(self.btn_search_clicked) | ||
self.ui.btnRefreshGames.clicked.connect(self.btn_refresh_games_clicked) | ||
|
@@ -118,6 +120,8 @@ def setup_game_list(self, row_count: int, header_labels: List[str]): | |
self.ui.txtNumGamesUsingTool.setText(str(row_count)) | ||
|
||
def update_game_list_ui(self): | ||
self.is_mark_global_available = is_mark_global_available(self.install_loc, self.ctool) | ||
|
||
# switch between showing the QTableWidget (listGames) or the QLabel (lblGamesList) | ||
self.ui.stackTableOrText.setCurrentIndex(0 if len(self.games) > 0 and not self.ctool.is_global else 1) | ||
self.ui.btnBatchUpdate.setEnabled(len(self.games) > 0 and not self.ctool.is_global) | ||
|
@@ -126,6 +130,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() | ||
|
||
|
@@ -161,3 +169,7 @@ def search_ctinfo_games(self, text): | |
for row in range(self.ui.listGames.rowCount()): | ||
should_hide: bool = not text.lower() in self.ui.listGames.item(row, 1).text().lower() | ||
self.ui.listGames.setRowHidden(row, should_hide) | ||
|
||
def btn_mark_global_clicked(self): | ||
self.is_mark_global_available = not set_launcher_global_tool(self.install_loc, self.ctool) | ||
self.btn_refresh_games_clicked() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reference to So if GE-Proton9-7's CtInfo dialog is open, and the global compat tool in However, it does update the compat tool list on the Main Menu to display And re-opening the dialog of course works as expected. I'm not sure how to fix this one, it is a bit of an edge-case and at worst something we can update in a later PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should disable the button after clicking because there currently is no visual feedback of the event.
That could be as simple as
self.btnMarkGlobal.setEnabled(false)
. We would need to add another check in the constructor so that the user won't click the button if it is already global.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's a good idea!
There's no reason to click this button again after marking a tool as global, at least not in the context of the currently open dialog.
An edge case could be opening two ctinfo dialogs at once, say GE-Proton9-7 and Luxtorpeda (just to have distinct examples). This is extremely unlikely to ever happen and could be alleviated with other behaviour, it's not a reason against implementing this button disabling but an outline of a potential problem scenario (although again, I really don't think anyone would do this if they weren't trying to break something)
A big way to alleviate this being a problem is the confirmation dialog noted earlier, because it would vastly reduce the likelihood of accidentally setting a tool as global.
There's also the possibility of closing the dialog which could be seen as expected since it's on the bottom row of the dialog buttons, but perhaps also not.
Disabling the button makes sense to me, I'll add it when I get home. I'm not sure if we want to close dialogs after a tool is marked as global, it might be a little jarring.
I also had a thought, I don't remember what happens if a tool is marked as global and then the game list is refreshed. If we get the "tool is global" text like if the user closed and re-opened the dialog, maybe the button also gets hidden, which I think is good too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, actually it seems like we don't hide the Mark Global button when the games list is refreshed.
We check if we should display the Mark Global button when loading the ctinfo dialog with
self.ui.btnMarkGlobal.setVisible(self.is_mark_global_available)
, perhaps we should also call this inupdate_game_list_ui
?I'm thinking we should rework the logic like this:
btnMarkGlobal.setVisible
call fromsetup_ui
.setup_ui
callsupdate_game_list
(updates launcher-specific UI elements) which in turn callsupdate_game_list_ui
(handles generic non-launcher-specific UI elements)update_game_list_ui
we can call check if the Mark Global button should be displayed usingself.ui.btnMarkGlobal.setVisible(self.is_mark_global_available)
(since we may want to display this for other launchers, andis_mark_global_available
will handle checking if Mark Global is available for the current launcher anyway)a. Right now the logic is only set if the current launcher is Steam, but with the recent refactor, we can call this generically and call this regardless of our current launcher, because
is_mark_global_available
is responsible for checking if the current launcher supports this actionself.ui.btnMarkGlobal.clicked.connect
action to connect the button logic fromupdate_game_list
toupdate_game_list_ui
a. Similar to above, this is also nested in a Steam-specific launcher check, but calling it from
update_game_list_ui
means we can connect this action regardless of launcher. Then the only thing we need to care about is ifis_mark_global_available
is True or False, and we don't need to care about knowing whether or not the launcher should support it, that's taken care of by the call tois_mark_global_available
.set_launcher_global_tool
to return a success booleanset_launcher_global_tool
to actually updateis_mark_global_available
, like this:self.is_mark_global_available = set_launcher_global_tool(self.install_loc, self.ctool)
. We could I guess hardcodeself.is_mark_global_available = False
but that would assumeset_launcher_global_tool
will always succeed. Ifset_launcher_global_tool
fails, this approach means we will update the value correctly.a. We could simply leave
set_launcher_global_tool
unchanged and instead make another call like this:self.is_mark_global_available = is_mark_global_available(self.install_loc, self.ctool)
to achieve the same thing. The approach here is more stylistic preference, although I think personally makingset_launcher_global_tool
return a success boolean is a bit cleaner.is_mark_global_available
and our existing call tobtn_refresh_games_clicked
will handle running all the checks again for whether or not the Mark Global button should be displayed, using the same refactored logic described above that we would use when the dialog opens.Basically we move the logic to set whether the button is visible or not into
update_game_list_ui
, meaning we will update it regardless of launcher, becauseis_mark_global_available
performs a launcher check for us. Then when we mark a tool as global, we update the value ofself.is_mark_global_available
. Finally our existing call to refresh the game list elements means we will pick up any changes tois_mark_global_available
and show/hide the button.The reason showing and hiding may be better is because we show/hide the button when the dialog opens.