Skip to content

Use a custom list widget in the Brush Preset History docker

Mike Will requested to merge myqwil/krita:master into master

I use the Brush Preset History docker when drawing, and sometimes with the stylus I will click-and-drag slightly, such that the initial press might start on one row, while releasing on another. That gesture does not register as an itemClicked event, so a different brush is not selected. However, as far as Qt is concerned, clicking and dragging on a QListWidget will select different rows as the cursor hovers over them (assuming drag-and-drop is disabled). As a result, the docker will indicate that a different brush has been selected, when in fact that brush has not been selected.

To fix this, I created a derived class of QListWidget, which emits a signal on left-mouse-button release events. The docker connects to this signal in exactly the same way that it used to connect to the itemClicked signal. The difference is that this approach basically guarantees that, so long as the user is using left-mouse clicks (or stylus taps) to select rows, the highlighted row will always properly reflect which brush has been selected.

Test Plan

Open a Brush Preset History docker (select some brushes to populate the list if necessary), hover the cursor over one of the rows, and press and hold the left mouse button. Then drag the cursor to a different row and release the left mouse button. A brush will be selected on the mouse-release event, and it should be the same brush as the currently highlighted row.

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

Loading