Add method of "editing" a pinned screenshot #3448
Open
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.
Add a method to allow editing a pinned screenshot by initiating a new screenshot over top of the pinned image, and then closing the old pinned image on success.
Apologies for not proposing this method on the linked issue first, I wanted to have a poke at the code today and didn't expect to get this far.
This adds a new context menu to pinned screenshots. When selected the PinWidget will call the daemon to do the work. Thus this functionality only works when flameshot is running in daemon mode. The context menu options don't show up when not running in daemon mode anyway (I don't know why they don't show up, other ones like the rotate and opacity ones also don't show up).
Here is a professional video recording off how it works:
editing_pins-2023-12-27_18.50.05.mp4
This doesn't actually edit the screenshot at all, I call it the "bait and switch" method of editing. The only previous attempt that I've seen to make pins editable got caught up in dealing with screens with different DPI (#1565). While it would be amazing to be able to limit the whole "grab" region to be less than a screen, or even just one screen, I think this method of editing a pin in the full desktop capture mode is a step forward. It sure is for my workflow anyhow.
I'm not familiar with c++ or this codebase so if there looks to be anything weird in this PR it's probably due to ignorance.
I'm calling FlameshotDaemon from PinWidget, I'm not sure if I should be doing that or trying to access the Flameshot singleton directly, I just copied off of another tool which called
FlameshotDaemon::copyToClipboard()
.I'm not sure if doing
.geometry() - .layout()->contentsMargins()
is the correct way to get the image geometry, I was guided by what attributes I could see in GammaRay while inspecting a running flameshot.The method of disconnecting from the signals from within the lambdas is from here: https://stackoverflow.com/questions/14828678/disconnecting-lambda-functions-in-qt5
I contemplated calling the method in Flameshot "replacePin" or "captureFromPin" or something more technically accurate. But I figured the signature could stay a bit optimistic and if people would like the behaviour to be firmed up to match the goal in the future that could be done. Eg add functionality to the CaptureWidget to make it so you can't modify the selection region, change the grab region to be less than the whole desktop etc.
Known issues:
Relates to: #954