Skip to content

Rework tooltips to show shortcut hints more consistently

Mathias Wein requested to merge mwein/krita:toolbox-tooltip-fix into master

While investigating the issue with the toolbox showing only hardcoded shortcuts, I realized Krita actually has a feature to show the keyboard shortcuts for most action tooltips, it just never got triggered until you accepted new Krita preferences.

It seemed odd to put that in KisPart (probably a relic when it had its own action collection, which I found is an orphaned private member), so I moved that part to KisActionRegistry. Instead of using regex to strip and re-add the shortcuts, I figured it's better to fetch the base definitions from the .action files that the registry has.

Then, I made the toolbox docker into a KisMainWindowObserver (for which I had to move it from the widgets to the ui library), so it can use the QActions that the tool factories create, and keep their tooltips updated. I'm not sure if that's the nicest way, but trying to somehow connect KoToolAction to emit update signals when action shortcuts change seemed awkward too, it just doesn't have any direct relation to that configuration but is more a static info object for the tool factories.

I guess some parts can still be made nicer, maybe we should get rid of the custom KoToolBoxButton altogether, aswell as the (already incomplete) duplications of shortcuts and tooltips in the individual tool factories.

Related bugs:
https://bugs.kde.org/show_bug.cgi?id=432070
https://bugs.kde.org/show_bug.cgi?id=425654

Test Plan

Check for action related tooltips (not justs the tool box docker) and check if they show shortcuts as expected, or are malformed in some way.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Edited by Mathias Wein

Merge request reports