AvengeMedia / AvengeMedia/DankMaterialShell

Clipboard History: preview action for image entries

Open
#3,368 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
QML
Stars
8.1k
Forks
515
Avg merge
1d 8h
Merged PRs (30d)
102

Description

### Feature Description

Clipboard History can already hold image entries and renders a thumbnail for them, but there is no way to actually look at one. There is currently no action to preview or open an image entry at a useful size; activating it only performs the existing copy/paste behavior.

**Current behavior**

- Left click on any entry copies it (or pastes it when `clipboardClickToPaste` is enabled) and closes the modal — `ClipboardEntry.qml` `mouseArea.onClicked`. There is no branch on entry type, so an image is activated by exactly the same code as a line of text.
- The right-click menu (`ClipboardContextMenu.qml`) offers Copy / Pin / Edit / Delete / Paste. `Edit` is hidden for images via `canEditEntry`.
- The row's **Edit** button is still rendered on image rows, but `ClipboardEntry.qml` returns early when `entryType === "image"`, so it does nothing at all.
- The thumbnail is capped at `sourceSize: 128` in `ClipboardThumbnail.qml`, so there is no full-resolution rendering of the entry anywhere in the shell.

Net result: after taking a screenshot, you can see a ~100px cropped thumbnail of it and nothing more. To check whether you captured the right region you have to paste it into some other application first.

**Proposed behavior**

1. **Left click stays exactly as it is** — copy, or paste when `clipboardClickToPaste` is on. This is deliberate: that behavior was made consistent with "Enter to Paste" in #2635 and should not regress. Preview is a *secondary* action, not a replacement for activation.
2. **Only image entries gain a Preview action.** Text and long-text entries are untouched.
3. **The dead Edit button on image rows becomes the Preview action**, with a fitting icon (`zoom_in` or `visibility`). This overlaps with #3355 — instead of adding a new affordance, it gives an existing but currently non-functional button a real job.
4. **Add `Preview` to the right-click menu**, shown for image entries only.
5. **Add `Open with…` as a further secondary action**, so an image entry can be sent to an external image editor/viewer — this is the Edit-button use case from #3355, applied to clipboard images rather than only to freshly captured screenshots. DMS already has precedent for handing screenshot files to an external editor through `DMS_SCREENSHOT_EDITOR`; similar integration may be reusable here if appropriate. Which mechanism is right — that setting, the existing app picker, or a more general abstraction — is best left to maintainers, since the screenshot path is tied to capture handling and may not generalise across compositors.

### Use Case

The main one is screenshots. On a compositor configured to send screenshots straight to the clipboard (for example niri with `screenshot-path null`), there is no user-visible screenshot file to open directly; the image is primarily surfaced through Clipboard History. That makes Clipboard History the natural place to answer "did I capture the right thing?", and right now it cannot answer it.

More generally: verifying which of several similar-looking images you are about to paste, and being able to hand one to an annotation tool without first pasting it somewhere else.

### Compositor(s)

All compositors

### Proposed Solution

**Why this fits the existing UX**

`ClipboardHistoryContent.qml` already implements exactly this pattern for text: a `mode` property that switches between `"history"` and `"editor"`, with `states`/`transitions` doing the crossfade and `ClipboardEditor.qml` providing a back-arrow header plus `Esc` to return. An image preview should be `mode: "preview"` in the same component — same surface, same transition, same escape behavior — rather than a separate window with its own conventions.

Rendering an image from a clipboard entry is also already solved twice in-tree: `ClipboardThumbnail.qml` and `ClipboardLauncherPreview.qml`, the latter with a `resolvedSourceUrl()` helper that builds a `data:;base64,…` URL for any `image/*` type.

**Implementation notes**

- `ClipboardHistoryContent.qml`: add `"preview"` to `mode` plus a `previewEntry()` function and a third `State`/`Transition`; route images out of `editEntry()` instead of returning early.
- New `ClipboardImagePreview.qml`: header/footer modelled on `ClipboardEditor.qml`, image loaded via a `resolvedSourceUrl()`-style data URL, drawn with `fillMode: Image.PreserveAspectFit` at the available size and **without** the thumbnail's `sourceSize` cap.
- `ClipboardEntry.qml`: swap the Edit button's icon/tooltip and emit a `previewRequested()` signal when `entryType === "image"`; `ClipboardContent.qml` wires it on both the recents and saved delegates.
- `ClipboardContextMenu.qml`: add the `Preview` item (and optionally `Open with…`) behind an `entry.isImage` check.
- `ClipboardHistoryModal.qml`: `closeOnEscapeKey` currently tests `!== "editor"` and would need to be `=== "history"`; `ClipboardKeyboardController.handleKey()` has a matching `mode === "editor"` guard.
- `ClipboardHistoryPopout.qml` needs no changes since it shares `ClipboardHistoryContent`, though the preview should be checked at the popout's smaller height.
- Secondary and not the point of this request: a keyboard shortcut for the selected entry. `Ctrl+O` looks free — the controller currently handles `Ctrl` with `N/J/P/K/C/S/E`.

### Alternatives/Existing Solutions

**Related issues**

- **#3355 — Edit button in Clipboard History for image entries** (open). Reports the dead Edit button and asks for it to open Satty. This request overlaps with it deliberately: point 3 gives that button a function, and point 5 covers the annotation-tool use case. Happy to see them handled together or for this one to be folded into #3355 if maintainers prefer.
- **#2635 — Make "Enter to Paste" clipboard setting consistent when also left clicking entries** (closed, completed). The reason point 1 keeps left click unchanged.
- **#3336 — Standalone Image viewer** (open). A separate, larger request for a general-purpose viewer application; a third-party plugin (`dankview`) came out of it. This request is much narrower: an in-modal preview for clipboard entries only, not a file-based image viewer.

**Existing solutions**: none in-shell. Today the workaround is to paste the image into another application (an editor, a browser, a chat window) purely to see it, which defeats the point of having the thumbnail in the list.

---

Checked against `master` today; the clipboard QML files are byte-identical to the 1.6.0 build I am running, so this is current behavior and not a packaging or version artifact.

Contributor guide

Open the contributing guide

Research direction

Start with ClipboardHistoryContent.qml, ClipboardEntry.qml, ClipboardContent.qml, ClipboardContextMenu.qml, and ClipboardHistoryModal.qml; compare ClipboardEditor.qml with ClipboardLauncherPreview.qml for the existing mode and image-loading patterns. Verify preview behavior in both the modal and popout, including Escape handling and smaller heights. Done means image entries have an in-shell preview while left-click behavior and text entries remain unchanged.

Written by the indexing model from the issue text.

Assessment

Domain
desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.