Skip to content

Use export action flags instead of several functions and signals

Noah Davis requested to merge work/ndavis/export-cleanup into master

This allows us to specify export actions and figure out which kinds of actions have been done simultaneously without having separate functions and signals for all the various combinations of save, save as, copy image and copy path.

SpectacleCore: Instead of storing which actions to use in boolean member variables, use a function to calculate which automatic export options can be done. This makes it so we don't need to update the variables every time we want to use them.

CaptureWindow, SelectionEditor, SpectacleCore: Don't export directly from CaptureWindows. Instead, pass export actions to the SpectacleCore::grabDone() signal via SelectionEditor::acceptSelection(). Necessary for preventing double saves when clicking the Save button in rectangle capture windows.

In order to cherry-pick this to 23.04, we'll need to cherry-pick some of the previous code clean-up and bug fix commits on master:

CCBUG: 422874 (needs new translatable strings to fully fix)

Tests to try:

# Verify that the image is both saved as "test.png" in the working directory and copied to the clipboard.
# There should be no notification and spectacle should end soon after the image is saved.
spectacle -n -i -r -b -c -o test.png
# Verify that the image is saved as "test.png" in the working directory and the path is copied to the clipboard.
# There should be a notification and spectacle should end when the notification expires.
spectacle -i -r -b -C -o test.png
# Click Save, verify that only one image is saved.
# There should be no notification and spectacle should end soon after the image is saved.
spectacle -n -r -b
# Click Save As, verify that the screenshot is saved at the specified location.
# Be aware that it might be in a different location than ~/Pictures.
# It should not be called "test.png" unless you explicitly named it that in the dialog.
# There should be a notification and spectacle should end when the notification expires.
spectacle -r -b -o test.png
Edited by Noah Davis

Merge request reports