Screenshot: optional automatic copy to the clipboard - #317
Merged
Conversation
A capture only reaches the clipboard when Copy is pressed in the floating preview, so the most repeated outcome of the tool, grab an area and paste it somewhere, costs a deliberate click every time. Turning on screenshotOpenEditorDirectly makes it worse rather than better: the preview is skipped entirely, and with it the only Copy button on that path, so the preference that speeds up annotating is the same one that slows down pasting. Add screenshotCopyToClipboard, off by default, and copy inside route() before the preview and editor branch, so the direct-to-editor path is covered too. The copy reuses flatten() and copyImage(), so the 1x downscale preference and the PNG plus TIFF pasteboard pair stay identical to every other copy in the app. Saving a file is untouched and remains an explicit choice. Success is silent: the preview or the editor is already appearing and says the capture happened, so a HUD would land on top of it and repeat
Contributor
|
I did something similar in #280 but took a different approach, a default action setting is added to Ask each time, save, save & copy, copy, or edit; if something other than ask each time is selected, the popup gets moved to the corner of the screen, appears for a shorter time, and disables buttons whose actions have already been taken by the default action. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behavior before
Every capture has to be routed by hand. The floating preview appears and the image only reaches the clipboard once Copy is clicked. With
screenshotOpenEditorDirectlyon there is no preview at all, so the fastest path to annotating is also the slowest path to pasting — the two preferences work against each other.For the common case of "grab this, paste it into a chat", that is one deliberate click on top of every single capture.
Behavior after
A new Copy to the clipboard automatically toggle in Settings → Screenshot, off by default, so nothing changes for anyone who does not turn it on.
When it is on, the capture is placed on the pasteboard as soon as the selection finishes, before the preview or the editor is shown.
Cmd+Vworks immediately. The preview still appears with all of its buttons; the editor still opens when the direct-edit preference is on. The two preferences are fully orthogonal:Saving to a file is untouched and stays an explicit choice from the preview or the editor.
Implementation
Four files, 53 added lines, nothing removed:
Core/Defaults.swift—screenshotCopyToClipboard, registeredfalse.Services/QuickTools/ScreenshotService.swift—route(_:)calls a new privateautoCopy(_:)before deciding between preview and editor, so the copy also covers the direct-to-editor path. It reuses the existingflatten(_:)pipeline, so the 1x downscale preference applies exactly as it does to the preview's Copy button, and the existingScreenshotEditorController.copyImage(_:), so the pasteboard gets the same PNG + TIFF pair as every other copy in the app.UI/Settings/ScreenshotSettings.swift— the toggle and its caption, in the output section above the save folder.Core/ScreenshotStrings.swift—autoCopyToggleandautoCopyCaptionin all 13 languages.No new dependencies, no new types, no changes to existing call sites.
Two decisions worth a second opinion
No HUD on success.
copyDirect(_:)shows the "Screenshot copied" HUD because the preview closes right after it, leaving nothing on screen. With auto-copy a surface is always about to appear, so a HUD would land on top of the preview and repeat what it already says. A failure still beeps, since an empty clipboard would otherwise only be discovered at the paste. Happy to add the HUD if you would rather have the confirmation.Annotations do not re-copy. If auto-copy puts the raw capture on the clipboard and the capture is then annotated in the editor, the clipboard still holds the un-annotated version until Copy is pressed in the editor. That is a real trap for anyone who edits, but fixing it means refreshing the pasteboard on editor close, which changes editor behavior and reads as a separate topic. Left out to keep this to one change; glad to open a follow-up if you want it.
Localization
autoCopyToggleandautoCopyCaptionare filled in for all 13 languages inScreenshotFeatureStrings: en, pt-BR, tr, ru, es, de, fr, it, ja, ko, zh-Hans, zh-TW, zh-HK. Terminology follows what the file andCore/Localizations/already use, notably 剪贴板 for zh-Hans and 剪貼板 / 拷貝 for zh-TW and zh-HK rather than 剪貼簿 / 複製, and zh-HK mirrors zh-TW here the same way the neighboringopenEditorstrings do.These are machine-assisted translations reviewed against the surrounding entries for tone and consistency, not native review. Please correct anything that reads wrong — I would rather the strings be right than mine.
Testing
./build.shcompletes with no warnings, before and after the change../build/Vorssaint --selftestprintsSELFTEST OK.I have not exercised an end-to-end capture on the built bundle: it is ad-hoc signed and would need its own Screen Recording grant alongside the installed copy, which I did not want to do on this machine. The change is small and reuses existing, already-tested copy and flatten paths, but the actual capture → clipboard round trip is unverified by me and worth a manual check before merging.
Notes
No existing issue covers this — I searched the tracker for screenshot and clipboard first and only found closed clipboard-history bugs. Happy to open a feature request to discuss it there instead if you would rather talk it through before looking at code.
Contributed under GPL-3.0-or-later per
CONTRIBUTING.md.