Skip to content

[not for 5.0] 438426 Implement user-consentable prioritization of image formats

This MR follows on !1177 (closed), and implements a consent flow for drag&drop and paste events, where the source application provides multiple formats for an image and/or its retrieval requires Internet access.

When such an event is detected, the new "Multiple Sources Detected" dialog will be fired. For instance, Firefox supplies a bitmap and a local BMP copy; the corresponding options are enabled:

Captura_de_pantalla_2022-01-14_103442

In the case of Chromium (Chrome/96.0.4664.137 as shipped by Vivaldi 5.0.2497.38), only the remote URL is supplied, and so the flows goes straight to a consent request:

Captura_de_pantalla_2022-01-14_103950

And, if accepted, the user will see how much the download takes (previously, Krita would just hang):

Captura_de_pantalla_2022-01-14_103857

Selecting the clipped bitmap will, as usual, trigger the "Missing Color Profile" dialog. This has also been overhauled to comply with the KDE design guidelines as well as the Windows Dialog Boxes design guide:

Captura_de_pantalla_2022-01-14_103456

As requested in the old MR, this version also refactors our clipboard handling, making sure we use as much common code as possible. Clipboard handling has been gatekept behind KisClipboard, and all format choices are handled by clip() and various other functions I've extracted (mainly to ensure they can act on the QEventDrop's mime data, instead of against the clipboard). I have also ensured that both file and paint device paths paste their layers at the drop's position; previously, only the former would do so, and only as a reference image (that was bug 446120).

BUG: 438426

Test Plan

Build Krita. Then,

  1. Create a new image.
  2. Drag&Drop an image from Chromium. Select "Insert as New Layer". Check that you're asked for consent to download the image.
  3. Repeat the same steps with Firefox. Check that you're offered the option to use the clipped bitmap or the local BMP copy.

With no image open:

  1. Close the image and repeat the steps with Chromium. Check that, again, you are asked for consent to download.
  2. Repeat the steps with Firefox. Check that it straight opens the BMP copy.

While at the New Document -> Create from clipboard:

  1. Check that there is no image available with Chromium.
  2. Check that, with Firefox, it detects the clipped bitmap in the preview, but on "Create" it asks you to choose which of the two to use.

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 Amy spark

Merge request reports

Loading