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

Games List: Search Box, Apply Button UX Tweaks #204

Closed sonic2kk closed 1 year ago

sonic2kk commented 1 year ago

Overview

This PR adds a search field to the Games List, my new favourite home it seems :sweat_smile: The idea behind this is to make it easier to find games to set compatibility tools for. The column sorting helps a lot and that was one of the reasons I had in mind for implementing it, but if you have hundreds or even thousands of games installed, it might be faster to just search for them.

This applies to all current Games List: Steam, Lutris, and Heroic (Proton+Wine).

Search

Screenshots: ![image](https://user-images.githubusercontent.com/7917345/225791082-b4c4ac5d-0d76-418d-80f5-f65459b51f5a.png) ![image](https://user-images.githubusercontent.com/7917345/225791095-eccf8c47-f29a-4001-a2d9-90bd58350d5b.png) ![image](https://user-images.githubusercontent.com/7917345/225791133-3e31d18d-c20d-4481-b6d0-34be510f483b.png) ![image](https://user-images.githubusercontent.com/7917345/225791152-a3a9862f-f44c-47b2-aa7e-622d39e6583b.png)

(I'll come back to the "Done" button in a bit)

The search field is hidden by default, and is shown when the user presses the new "Search" button. It shows up in the same position as the Steam warning label. If the label is not displayed, there is no change, but if it is displayed, then this label is temporarily hidden while the search field is present.

Searching preserves the current selected column sort, and sorting works even when the user is in the middle of searching. It also keeps this sort. If the user searches for, say, "Persona", and sorts alphabetically, then this sort will be remembered. Of course, selected compatibility tools are remembered as well!

When the user presses the "Done" button, the search filter is cleared. Once the user presses "Search" again, their last remembered search will be applied as well.

The Search field is automatically focused when the "Search" button is pressed, so the user can start typing right away. This may also help with virtual keyboards on Wayland, though I haven't tested :-) That's more up to the Desktop Environment and virtual keyboard library to detect, but it was something I considered as part of implementing that logic and so wanted to mention it.

UI Tweaks

There are also a a couple of smaller changes to the Games List UI logic:

Improvements

There are a couple of things I would like to "Improve" on this PR that I'd like some feedback on.

Keyboard Shortcuts

The decision to have a dedicated "Search" button was deliberate, for users who may be using a touch screen (i.e. on Steam Deck). But I would also like the ability to trigger this with a standard Ctrl+F shortcut. I'm not sure how to do this though. The btn_search_clicked method would need to be called on Ctrl+F being pressed. I read online about a QKeySequence being used for this, and it can emit an activated but I'm not totally sure, I couldn't find too much (though it is late at the moment).

This may be a bit convoluted or over-the-top but it would also be nice if pressing "Escape" with the search field highlighted could perform some actions.

This may be too complex to implement and not worth the effort, but it was an idea I had after opening the PR and experimenting with actually using the search box and behaviour that I would "expect".

"Done" Button for Search

My other concern is with the "Done" button for the search field. I'm not too sure if this name is good. It may be confusing for users. "Stop Searching" is a bit lengthy but could work as a replacement. Some way to better name this button would be appreciated :smile:

One potential solution is to have a layout with the search field that has its own "Done" button (which could be connected to the same signal as the "Search" button probably), and that button would then appear directly to the right of the search field, and would be shown and hidden with that field. That way the "Done" button is farther away from the "Close"/"Apply" button, but it could still end up being confusing.

Performance?

I only have around 307 Steam games installed, but on my PC the search is instantaneous. Maybe if there were thousands of games there could be a performance impact here. If there are ways to optimise the search I'm very open to it! :smile:

Future Implementations

This could be implemented in the compat tool about dialog. A user may be a bit more cramped for space here to include the button and search field but it should still work.

Search Criteria

A user can only search by Game Name. I wasn't sure how to implement searching by AppID in a clean way and I wasn't sure how useful it would be to begin with - if a user knows the AppID for a game off the top of their head, they probably also know the game name.

Translations

The placeholder/background/"hint" text is added to the .ui file edited in Qt Designer, so I am not sure how to handle the translations. Sorry :sweat:


I thought my last PR would be my last contribution for a while, but I found a note written down with this idea out of the blue and thought I'd try to implement it and keep the code cost down (tried to keep the Games List under 400 lines but failed...)

Thanks! :-)

sonic2kk commented 1 year ago

Pushed a small commit that now prefixes the dialog title with the current launcher e.g. "Steam Games List", "Heroic Games List".

I took a stab at implementing the Ctrl+F keyboard shortcut for the games list. This seems to work, though it had to be set twice: In setup_ui and then again in btn_search_clicked. I'm not sure why it has to be set in here again so if this can be fixed I'm very open to that :-)

Still not sure how to implement the "Escape" shortcut I talked about.


Also as a small note: The black text for the search box hint is a KDE bug with Qt6 applications. Here's an example with the light theme:

![image](https://user-images.githubusercontent.com/7917345/226119965-9e95ab34-dd84-433d-be0d-26c82a9e8036.png)
sonic2kk commented 1 year ago

Pushed a couple of commits which do the following:


The more I look at the search bar UI, the more I think we should hide the search button when the search bar is visible, and show a "Done" button beside the search bar that gets shown/hidden with it. But I'm not sure if having a bunch of hidden widgets is such a good idea. We could also just move the search button if that's possible.

DavidoTek commented 1 year ago

Thanks, that is a nice addition! :tada:

The search field is hidden by default, and is shown when the user presses the new "Search" button. It shows up in the same position as the Steam warning label. If the label is not displayed, there is no change, but if it is displayed, then this label is temporarily hidden while the search field is present.

Sounds good.

The decision to have a dedicated "Search" button was deliberate, for users who may be using a touch screen (i.e. on Steam Deck). But I would also like the ability to trigger this with a standard Ctrl+F shortcut.

That's very good, having suport for mouse and touch screens as well as a keyboard shortcut.

I only have around 307 Steam games installed, but on my PC the search is instantaneous. Maybe if there were thousands of games there could be a performance impact here. If there are ways to optimise the search I'm very open to it! smile

Code looks good. Looping over hundreds (or few thousands) of items once and doing a simple string comparison should be fast enough with Python.

This could be implemented in the compat tool about dialog. A user may be a bit more cramped for space here to include the button and search field but it should still work.

Yeah, that could be an optional future addition. Having it in the Game List should be enough for now.

The placeholder/background/"hint" text is added to the .ui file edited in Qt Designer, so I am not sure how to handle the translations. Sorry sweat

No worries. Ui file translations are automatically included by Qt.

Also as a small note: The black text for the search box hint is a KDE bug with Qt6 applications

I also noticed some problems with some themes. I may need to change the custom theme, specified in constants.py.

The more I look at the search bar UI, the more I think we should hide the search button when the search bar is visible, and show a "Done" button beside the search bar that gets shown/hidden with it. But I'm not sure if having a bunch of hidden widgets is such a good idea. We could also just move the search button if that's possible

In theory, we could add a little X action button besides the text field, though people might confuse it with "clear text box". Personally, I think it looks okay as it is.

I thought my last PR would be my last contribution for a while, but I found a note written down with this idea out of the blue and thought I'd try to implement it and keep the code cost down (tried to keep the Games List under 400 lines but failed...)

Yeah, there is always something you will find to improve/change. As always, thanks for looking into those :smile: