DavidoTek / ProtonUp-Qt

Install and manage GE-Proton, Luxtorpeda & more for Steam and Wine-GE & more for Lutris with this graphical user interface.
https://davidotek.github.io/protonup-qt
GNU General Public License v3.0
1.22k stars 40 forks source link

pupgui2: Add More Keyboard Shortcuts #209

Closed sonic2kk closed 1 year ago

sonic2kk commented 1 year ago

Implement #206.

This is currently missing the shortcuts for the compatibility tools, but should have the rest as described in that issue:

For the compatibility tools, the PupguiInstallDialog could have a method to set the selected compatibility tool. We could then pass an optional parameter to MainWindow#btn_add_version_clicked which would specify the tool. A lambda something like this would then be attached to the shortcut:

# MainWindow
def setup_ui(self):
    # ...
    QShortcut(QKeySequence('Ctrl+Alt+T'), self.ui).activated.connect(lambda: self.btn_add_version_clicked(compat_tool='Proton-tkg'))
    # ...

Aside from having to modify some of the install dialog logic, the cost to implement the majority of these shortcuts seems quite low (one line each!), which is always a good thing :smile:

sonic2kk commented 1 year ago

Added an initial implementation of having shortcuts to open the dialog for a given compatibility tool.

Currently they are all Steam compat tools, and if you have say Lutris selected, these shortcuts will still open the versions dialog. This isn't ideal of course. Probably these shortcuts could be moved into a setup_shortcuts method for MainWindow, which will check the launcher before binding the shortcuts. Though I'm not sure how this would work, since once the shortcuts are created, I don't know if they're ever "unbound". Dynamic shortcuts like these may not really be an "intended" use-case.

It's something I'll keep looking into :slightly_smiling_face:

sonic2kk commented 1 year ago

Thought about this a bit, got a coffee, and came up with something, but it still isn't perfect.

I added a boolean check to the PupguiInstallDialog#set_selected_compat_tool dialog method, and then we just won't show the dialog if the check returns False. However this is not great because it still instantiates the dialog, and as a side effect, counts towards the rate limit. So you could spam the shortcut and still hit the rate limit.

Probably it's better to have a helper/utility method that can check the ctobjs that the dialog would have, and have that method outside of the dialog. Then we can have a separate method that checks this before we try to instantiate the dialog.

sonic2kk commented 1 year ago

Created the helper method as described and put it in util.py. Now we only create the dialog if we can find the name passed in among the list of available ctmods in the ct_loader for the given launcher install location (if the given compat_tool name is truthy).

I think this is a cleaner approach than the one I had in https://github.com/DavidoTek/ProtonUp-Qt/pull/209/commits/649a51a30692fcd7856e22110c95541803c6aeae, but there may yet still be room for improvement :-)


On the back of this check, I went ahead and added some shortcuts for Lutris. I added shortcuts for DXVK, Lutris-Wine and Wine Tkg. Though on my system the Lutris-Wine shortcut Ctrl+Shift+L doesn't seem to work. When I add a different key sequence, the shortcut works, so perhaps a different shortcut is needed for Lutris Wine, if this isn't some strange issue specific to my system :sweat_smile:

DavidoTek commented 1 year ago

Aside from having to modify some of the install dialog logic, the cost to implement the majority of these shortcuts seems quite low (one line each!), which is always a good thing :smile:

Good. That means we are flexible to add/change shortcuts in the future.

Though on my system the Lutris-Wine shortcut Ctrl+Shift+L doesn't seem to work.

Some shortcuts may be reserved by the desktop/some other program. But they are different depending on the desktop environment.

Thanks! :partying_face: