Clipboard plugin: allow syncing images
Currently we only sync the clipboard if it contains text. However, the clipboard can contain a variety of data. One of the most common cases besides text are images.
The APIs we use to read the clipboard let us read and write images:
- In Qt the clipboard has a
mimetype
field of typeQMimeData
which can be asked forhasImage
(in addition tohasUrls
andhasHtml
[1]) - On the Android side, we can use
ClipboardManager
'ssetPrimaryClip
to set the different types of clipboard.
To support this, in addition to the text-only "content" field we will need to send a mime-type
field with the mimetype of the clipboard. For image (or any future non-text) mimetypes, an attached payload will contain the image data.
To not transfer huge payloads because of this, we should set an upper size limit (eg: 1 MB, we can change this in a future or even make it configurable).
Related bugzilla ticket: https://bugs.kde.org/show_bug.cgi?id=451258
[1] We probably don't care about URLs because they can be sent as text and they still work, but in a future it might be interesting to also support HTML so we can sync formatted text.