Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions data/be.alexandervanhee.gradia.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<default>false</default>
<summary>Overwrite currently opened screenshot on close</summary>
</key>
<key name="close-after-copy" type="b">
<default>false</default>
<summary>Close the window automatically after copying the image to the clipboard</summary>
</key>
<key name="custom-export-command" type="s">
<default>''</default>
<summary>Custom command to run when pressing its button</summary>
Expand Down
8 changes: 8 additions & 0 deletions data/ui/preferences_window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ template $GradiaPreferencesWindow: Adw.PreferencesDialog {
activatable: true;
}

Adw.SwitchRow close_after_copy_switch {
title: _("_Close After Copying");
use-underline: true;
subtitle: _("Exit the app once the image is on the clipboard");
tooltip-text: _("Close the window after copying the image to the clipboard");
activatable: true;
}

Adw.SwitchRow delete_screenshot_switch {
title: _("_Trash Screenshots on Close");
use-underline: true;
Expand Down
4 changes: 4 additions & 0 deletions gradia/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ def exit_method(self, value: str) -> None:
def overwrite_screenshot(self) -> bool:
return self._settings.get_boolean("overwrite-screenshot")

@property
def close_after_copy(self) -> bool:
return self._settings.get_boolean("close-after-copy")

@property
def custom_export_command(self) -> str:
return self._settings.get_string("custom-export-command")
Expand Down
2 changes: 2 additions & 0 deletions gradia/ui/image_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ def _on_task_complete(source_object, result, user_data):
if not silent:
self.window.show_close_confirmation = False
self.window._show_notification(_("Image Copied"))
if self.window.settings.close_after_copy and self.window.settings.exit_method != "copy":
self.window.close()

except Exception as e:
self.window._show_notification(_("Failed to copy image to clipboard"))
Expand Down
2 changes: 2 additions & 0 deletions gradia/ui/preferences/preferences_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PreferencesWindow(Adw.PreferencesDialog):
save_format_group: Adw.PreferencesGroup = Gtk.Template.Child()
delete_screenshot_switch: Adw.SwitchRow = Gtk.Template.Child()
overwrite_screenshot_switch: Adw.SwitchRow = Gtk.Template.Child()
close_after_copy_switch: Adw.SwitchRow = Gtk.Template.Child()
confirm_upload_switch: Adw.SwitchRow = Gtk.Template.Child()
save_format_combo: Adw.ComboRow = Gtk.Template.Child()
provider_name: Gtk.Label = Gtk.Template.Child()
Expand Down Expand Up @@ -161,6 +162,7 @@ def _bind_settings(self):
self.settings.bind_switch(self.delete_screenshot_switch,"trash-screenshots-on-close")
self.settings.bind_switch(self.confirm_upload_switch,"show-export-confirm-dialog")
self.settings.bind_switch(self.overwrite_screenshot_switch,"overwrite-screenshot")
self.settings.bind_switch(self.close_after_copy_switch,"close-after-copy")

@Gtk.Template.Callback()
def on_choose_provider_clicked(self, button: Gtk.Button) -> None:
Expand Down