Repository navigation
feat(clipboard): accept dropped content - #3211
Conversation
|
/claude review |
| const url = drop.urls[0].toString(); | ||
| if (url.startsWith("file://")) { | ||
| const filePath = decodeURIComponent(url.substring(7)); | ||
| DMSService.sendRequest("clipboard.copyFile", { "filePath": filePath }, response => { |
There was a problem hiding this comment.
clipboard.copyFile doesn't just add to history — Manager.CopyFile ends with m.takeSelection(offers) (core/internal/server/clipboard/manager.go:1926), so it takes over the Wayland selection and replaces whatever the user currently has copied. The text branch below uses clipboard.store, which only appends to history. Dropping a file therefore silently clobbers the clipboard, which is neither what the PR describes ("save ... to clipboard history") nor consistent with the text path.
If history-only was intended, clipboard.store handles URI lists (StoreData builds a proper preview for text/uri-list):
DMSService.sendRequest("clipboard.store", { "data": url, "mimeType": "text/uri-list" }, ...)| onDropped: drop => { | ||
| draggingOver = false; | ||
| root.handleDrop(drop); | ||
| } |
There was a problem hiding this comment.
The drop event is never accepted. QQuickDropArea::dropEvent only emits dropped; it doesn't accept the underlying QDropEvent, so the drag source is told the drop was refused and shows failure feedback (snap-back animation in most file managers/browsers) even though the item was saved.
Accept explicitly with Qt.CopyAction — accepting the proposed action would let a source that proposed MoveAction delete the original (e.g. text dragged out of an editor):
| onDropped: drop => { | |
| draggingOver = false; | |
| root.handleDrop(drop); | |
| } | |
| onDropped: drop => { | |
| draggingOver = false; | |
| drop.accept(Qt.CopyAction); | |
| root.handleDrop(drop); | |
| } |
| property bool draggingOver: false | ||
|
|
||
| DropArea { | ||
| anchors.fill: parent |
There was a problem hiding this comment.
The parent here is the content item, which is only icon.width wide and widgetThickness - horizontalPadding * 2 tall (14px of a 30px pill with the default widgetPadding: 8) — the icon itself overflows it. The drop target is thus much smaller than the visible button, and drops on the pill's padding do nothing. Expanding by the padding makes it match visualWidth/visualHeight:
| anchors.fill: parent | |
| anchors.fill: parent | |
| anchors.margins: -root.horizontalPadding |
Claude reviewNice feature, three things to fix before merge — one behavioral, two around the drop plumbing.
Checked: IPC method/param names against core/internal/server/clipboard (both valid), DMSService callback error shape, BasePill content sizing, service/import availability, translation catalogs untouched. Model: claude-opus-5. |
|
/claude review |
| if (drop.hasUrls && drop.urls.length > 0) { | ||
| const url = drop.urls[0].toString(); | ||
| if (url.startsWith("file://")) { | ||
| DMSService.sendRequest("clipboard.store", { | ||
| "data": url, | ||
| "mimeType": "text/uri-list" | ||
| }, response => { | ||
| if (response.error) { | ||
| ToastService.showError(I18n.tr("Failed to save dropped file")); | ||
| return; | ||
| } | ||
| root.showDropConfirmation(); | ||
| }); | ||
| return; | ||
| } | ||
| } |
There was a problem hiding this comment.
Only urls[0] is stored, so a multi-file drag (a normal gesture from any file manager) silently drops everything but the first file — and still flashes the success check, so the user has no way to notice. text/uri-list is a CRLF-separated list and the backend already handles it: uriListPreview returns [[ N files ]] for multi-URI data (core/internal/server/clipboard/manager.go:749).
Collect all file:// entries instead:
if (drop.hasUrls && drop.urls.length > 0) {
const fileUrls = drop.urls.map(u => u.toString()).filter(u => u.startsWith("file://"));
if (fileUrls.length > 0) {
DMSService.sendRequest("clipboard.store", {
"data": fileUrls.join("\r\n"),
"mimeType": "text/uri-list"
}, response => {
if (response.error) {
ToastService.showError(I18n.tr("Failed to save dropped file"));
return;
}
root.showDropConfirmation();
});
return;
}
}
Claude reviewPrevious round is addressed — file drops now use
Checked: |
|
/claude review |
| "mimeType": "text/uri-list" | ||
| }, response => { | ||
| if (response.error) { | ||
| ToastService.showError(I18n.tr("Failed to save dropped file")); |
There was a problem hiding this comment.
These two new terms (here and line 64) have no translator context. CONTRIBUTING.md requires I18n.tr("...", "<context>") for new user-facing strings, and asks to keep new terms to a minimum — a single term like I18n.tr("Failed to save dropped content", "Error toast when a drag-and-drop onto the clipboard bar widget could not be stored") would cover both branches.
Claude reviewPrevious round of findings looks addressed; one minor i18n issue left.
Checked: drop handling and uri-list payload against |
Allow users to save dropped text and local files to clipboard history directly from the Clipboard bar widget. Successful drops show a temporary primary-colored check icon instead of a success toast.
Partially addresses #2748.
recording_20260828_221148.mp4