Bug 492005 - Klipper puts "application/x-kde-onlyReplaceEmpty" first when it should be near the end of the mimetype list
Summary: Klipper puts "application/x-kde-onlyReplaceEmpty" first when it should be nea...
Status: RESOLVED NOT A BUG
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 6.5.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2024-08-21 21:20 UTC by TraceyC
Modified: 2024-08-22 16:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description TraceyC 2024-08-21 21:20:33 UTC
SUMMARY
Split from bug 491961
When Spectacle is set to auto copy an image, and a screenshot other than rectangular area is taken, it cannot be pasted in in Dolphin without manually picking its filetype

Per 491961, this has 3 different contributing factors requiring 3 different reports.
1. Klipper doesn't preserve "application/x-kde-suggestedfilename". Bug 491961
2. Klipper puts "application/x-kde-onlyReplaceEmpty" first when it should be near the end of the mimetype list.
3. KIO's paste dialog shouldn't offer custom KDE mimetypes that are only used as hints.

STEPS TO REPRODUCE
- Open Dolphin

Spectacle Settings:
- When launching, do not take screenshot automatically
- After taking screenshot, copy image to clipboard

1. Copy an image from spectacle, use any type of screenshot except Rectangular Region
2. Attempt to paste the image into Dolphin with Ctrl V
3. Enter a name at the prompt (Note: when the content is properly pasted, the name is auto suggested like with saving to file ex Screenshot_date-time.ico)

OBSERVED RESULT
The name field is blank
The Data type is "application/x-kde-onlyReplaceEmpty"
Nothing is pasted to the folder in Dolphin

EXPECTED RESULT
The name is pre-populated in keeping with the default name settings in Spectacle's settings
The Data type matches the image format (png, tiff, jpg etc)
The image is pasted as a file in the folder in Dolphin

SOFTWARE/OS VERSIONS
KDE Plasma git-master on Solus

ADDITIONAL INFORMATION
Clicking the Copy button in Spectacle allows the image to be pasted in Dolphin as normal

Discovered when testing !391
https://invent.kde.org/graphics/spectacle/-/merge_requests/391
Comment 1 Nate Graham 2024-08-22 15:28:36 UTC
Relevant stuff is in src/widgets/paste.cpp
Comment 2 Noah Davis 2024-08-22 15:40:29 UTC
I've determined that Klipper is not actually at fault. It's actually a KIO paste dialog problem that "application/x-kde-onlyReplaceEmpty" comes first. Klipper puts it last in the format list like it should. In bug 491961 I assumed that the paste dialog formats followed the order of the formats list since the image formats were shown in that order, but I suppose it's slightly different. For posterity, the real bug is bug 492006.
Comment 3 Noah Davis 2024-08-22 16:59:15 UTC
After a bit more testing, it's still technically an issue for KIO, but the actual source of the format ordering issue is probably something more internal to Qt. It seems that first Klipper uses QMimeData::setImageData, which only sets "application/x-qt-image". After that, Klipper sets "application/x-kde-onlyReplaceEmpty". Slightly later it appends all the other image formats. This is why "application/x-kde-onlyReplaceEmpty" shows up before PNG. It seems like you can't assume that hint mimetypes will go after the automatically set image types even if you set them after QMimeData::setImageData.