diff --git a/data/be.alexandervanhee.gradia.gschema.xml b/data/be.alexandervanhee.gradia.gschema.xml index 4e4adc5..e45175e 100644 --- a/data/be.alexandervanhee.gradia.gschema.xml +++ b/data/be.alexandervanhee.gradia.gschema.xml @@ -76,6 +76,10 @@ false Overwrite currently opened screenshot on close + + false + Close the window automatically after copying the image to the clipboard + '' Custom command to run when pressing its button diff --git a/data/ui/preferences_window.blp b/data/ui/preferences_window.blp index e0e6869..984a66a 100644 --- a/data/ui/preferences_window.blp +++ b/data/ui/preferences_window.blp @@ -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; diff --git a/gradia/backend/settings.py b/gradia/backend/settings.py index 06ef0bc..68d3414 100644 --- a/gradia/backend/settings.py +++ b/gradia/backend/settings.py @@ -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") diff --git a/gradia/ui/image_exporters.py b/gradia/ui/image_exporters.py index 5a3477b..c7b5e37 100644 --- a/gradia/ui/image_exporters.py +++ b/gradia/ui/image_exporters.py @@ -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")) diff --git a/gradia/ui/preferences/preferences_window.py b/gradia/ui/preferences/preferences_window.py index eb5acdb..2300094 100644 --- a/gradia/ui/preferences/preferences_window.py +++ b/gradia/ui/preferences/preferences_window.py @@ -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() @@ -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: