-
-
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
Display shortcuts for tool bar buttons in their tool tip #1492
Comments
Working on this as my first contribution. Anything I should know? Seems pretty straight forward. |
@laspencer91 I think the issue description is quite complete. Thanks for working on this and I'm curious to see your solution! |
Had tons of homework today, still digging through the code but I think I do have a solution. Will start to implement tomorrow! |
Update on this: So now we have a list of all of the actions that reside on the toolbars. (I filter out QAction seperators etc.) The class is flexible and easy to use. For example to update a shortcut text(or even the shortcut for that matter) of a specific action you can simply use. Or for example after an option is created to change shortcut keys you could simply call: The text for the shortcuts is added on by changing the toolTip for that specific action: Let me know if you hate this, or if there already exists a list of all these actions somewhere (I didn't find one), and if there isn't a list of all of these I think that it is very benificial to have with easy access too. Remember this isn't just access to its toolTip text, this is access to the pointers to the actual QActions. Again, its very simple and clean to use. I am creating it as flexible as possible for future uses. |
Hmm, I would prefer to do it in a little more controlled way rather than searching the widget hierarchy for actions. I had personally started an But maybe there is something to be said for your approach, which of course reduces the amount of manual effort and code changes. Feel free to just open a pull request so I can look at the changes in more detail and try it out. |
Also, I considered that maybe we could have an Action class derived from QAction, where you can set the baseToolTip and the actual toolTip would be based on the baseToolTip and the shortcut text. That way you avoid the somewhat hacky parsing of parenthesis when the shortcut is changed. |
I understand your concern, but the actions do not have to be added by the hierarchy like that. You can add actions into the List one by one, or add additional actions later on. The only reason I did it like that is because it is the cleanest way to get all of the actions on initialization. For example this grabs all the actions. The first statement creates a temporary list. The second statement adds all of the dockWidgets found, and the third statement populates the actionList by looking at the dockWidgets. This is just placed at the end of the mainWindow constructor and I found it to be the easiest way on initialization. You could instead add each action manually with I also considered your second point, I will open a request in about an hour and a half. |
I've implemented this functionality in change 2e53f96. In the end I also went for cutting a previously added shortcut away when updating the tool tip with a potentially new shortcut. Rather than searching the UI for shortcuts though, each action needs to be registered. This not only enables showing the shortcut in the tool tip but was also necessary to make that shortcut configurable (for which the action needs an associated ID). |
For discoverability of shortcuts it would be nice if the tool tip of actions on tool bars would display their shortcuts where available. This already happens for the editing tools, but it would be nice to have a more general solution.
These tool tips needs to be added to the tool tip dynamically, especially since the plan is to eventually allow the shortcuts to be configured (#215).
The Qt Creator IDE already implements a solution for this, which can be looked at for inspiration.
Mentioned by Hawken King on the forum.
The text was updated successfully, but these errors were encountered: