Skip to content

Fix Resource Item Chooser issues (including Bug 439718)

Mathias Wein requested to merge mwein/krita:bug_439718_resource-choosers into master

This probably made some more of my hairs grey... So there were a bunch of small yet tricky issues that made the KisResourceItemChooser behave strange, and I hope I finally managed to solve them in a non-hacky way.

The changes are:

  • Fix the SQL query used by KisTagResourceModel to get the storage of a resource, required to determine the "dirty" state
  • Implement an optional stricter SingleSelection behavior for KisResourceItemListView:
    • when the model removes rows, QListView just selects the next best item in SingleSelection mode, this caused the change of brush presets when you type in the search field.
    • With Ctrl+click on an item, you could deselect it, but you cannot "unswitch" a resource, so I've overridden that behavior too.
  • KisResourceItemChooser now uses the stricter mode, and remembers the current resource. This way, filtering out the current resource gives an empty selection, and clearing the filtering will have it selected again, since it's still active after all.
  • The Brush Preset Docker did not select the current preset on startup
  • By chance, I figured out why the resource manager doesn't update the selection display properly. That was because we reimplemented QListView::selectionChanged() without calling the base class implementation, which is responsible for viewport update.

Test Plan

Basically, play with all resource choosers you find, using tag and text filtering, and check if they behave correctly.

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.

Merge request reports