-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
"Search actions" widget #3449
"Search actions" widget #3449
Conversation
First of all, thank you so much for looking into this feature! De-duplicate codeI'm mentioning this first because I think it has priority over other improvements. I'd suggest to take it one step at a time. The most similar class seems to me to be Second, I don't think we need an additional delegate, especially since the delegate is just working with a string and not directly with the Talking about the Finally, there is the
Since the locator sources don't store any relevant state they can be constructed on-demand along with the auto source = files ? new FileLocatorSource : new ActionsLocatorSource;
mLocatorWidget = new LocatorWidget(source); The Show iconsAs mentioned previously, I'd do this the usual way, by supporting Filtering based on contextI actually don't know if there is a good way to do this, but I guess you'd have to see if the icon is currently visible, taking into account whether its parent menu is visible. This could be problematic, because actions can be part of multiple menus or also tool bars. Of course, if we're lucky then Qt provides some way to detect this. It may have some way to know internally because a hidden action no longer triggers based on its shortcut, but the implementation of that might not be exposed in any helpful way. |
Since later on I realized we're instantiating this widget on-demand and deleting it again when it closes, we could actually use sub-classing, but I'd still prefer if the shared part and the polymorphic part were clearly separated, as suggested. |
Thank you very much for the guidance. It will take a while for me to implement this but your posts will help a lot |
5081d10
to
ae2c76f
Compare
…jectModel::Match struct to LocatorWidget
* Fixed indentation for ActionSearchWidget. * Removed unnecessary LocatorMatchesModel base class. * Moved delegate back to LocatorWidget, until we have a reason to move it to the LocatorSource interface. * Moved splitting of filter text into words back to LocatorWidget. * Moved LocatorMatch back to ProjectModel::match. * Removed data members from LocatorSource interface. * Don't inherit LocatorSource interface from QObject.
Introducing ActionLocatorSource to provide the custom placeholder text, model and activation logic.
I've finished de-duplicating the code. Now the main issues are the customization that is still needed for the action search, like showing icons and shortcuts, not displaying the action text twice (remnant of reusing file delegate). Whether that is best done by extending the Actions also get penalized in |
Seems like a nice simplification.
Text still needs to be moved to make space for the icon and the shortcut still needs to be added on the right.
Also fixed "Custom Types Editor" action to be registered.
I think this is almost ready to be merged, but I have a few concerns:
Unfortunately, with the holidays starting now, I won't have much time until next year, but I think there is no good reason to rush this in now. |
A few of the tools register their actions with the same Ids. They do this because to the user there is only one such action, and they share the any custom shortcut. When triggering these actions, we need to make sure to trigger them for the right tool. Implemented solution is to disable actions from inactive tools, and search for the first enabled action for each registered Id.
When using Qt 6 on Windows, the LocatorWidget could get destroyed as a result of activating some actions, like when they open a file dialog. This caused a crash because then after the action is triggered, close() was called on a deleted object. It should be no problem to call close() before triggering the action, since the actual deletion of the LocatorWidget is delayed so mLocatorSource should stay valid.
Instead of ignoring the action when the locator widget is already open, close any existing one and replace it with the new.
Also adjusted the section about creating a new project to the behavior in Tiled 1.9.
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.
Great work getting this feature started and functional @dogboydog! I think it is now polished enough for merging. Further improvements can be made later, like the hiding of some more actions when they are out of context or displaying the menu in which the action resides.
As-is, I think the feature is very helpful and I don't think we have any crashes left to fix (though I didn't try to trigger all actions, heh).
Thank you so much Bjorn. I'm sorry i couldn't get further on it, I hit a wall there with my skill level. Looking forward to using the final version -- been using a CI build with the feature enabled for a few weeks |
This widget can be used to quickly search actions by name, including those from scripts. Click an action in the results triggers it.
action_search.mp4
Some items I'd like input on so that I could try to implement them (maybe if you could point me to relevant files/code):
Show icons for each action in the list
Filter actions based on which are possible with the active asset (don't show map properties when editing a tileset, for example). Also exclude "search actions" itself from the list
De-duplicate code between actionsearchwidget and locatorwidget
I'm sure lots of refinement will need to be done before it's ready. I had another branch with an attempt to deduplicate the code, but can't get it back to a state that builds anyway so might as well just start over with that based on your feedback.