feat: add dialog for clear all threads
All checks were successful
ci/woodpecker/push/<no value> Pipeline was successful
All checks were successful
ci/woodpecker/push/<no value> Pipeline was successful
This commit is contained in:
parent
32f0bea20a
commit
d6d834495b
|
@ -26,12 +26,12 @@ template $Preferences : Adw.PreferencesWindow {
|
||||||
title: _("Miscellaneous");
|
title: _("Miscellaneous");
|
||||||
|
|
||||||
Adw.ActionRow {
|
Adw.ActionRow {
|
||||||
title: _("Clear all chats");
|
title: _("Clear all threads");
|
||||||
|
|
||||||
Button clear_all_chats_button {
|
Button clear_all_chats_button {
|
||||||
valign: center;
|
valign: center;
|
||||||
label: _("Clear");
|
label: _("Clear");
|
||||||
tooltip-text: _("This will clear all chats from the database.");
|
tooltip-text: _("This will clear all threads from the database.");
|
||||||
clicked => $clear_all_chats_clicked();
|
clicked => $clear_all_chats_clicked();
|
||||||
styles ["destructive-action"]
|
styles ["destructive-action"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,11 +68,30 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
||||||
|
|
||||||
@Gtk.Template.Callback()
|
@Gtk.Template.Callback()
|
||||||
def clear_all_chats_clicked(self, widget, *args):
|
def clear_all_chats_clicked(self, widget, *args):
|
||||||
self.app.clear_all_chats()
|
dialog = Adw.MessageDialog(
|
||||||
|
heading=_("Delete All Threads"),
|
||||||
|
body=_("Are you sure you want to delete all threads? This can't be undone!"),
|
||||||
|
body_use_markup=True
|
||||||
|
)
|
||||||
|
|
||||||
toast = Adw.Toast()
|
dialog.add_response("cancel", _("Cancel"))
|
||||||
toast.set_title(_("All chats cleared!"))
|
dialog.add_response("delete", _("Delete"))
|
||||||
self.add_toast(toast)
|
dialog.set_response_appearance("delete", Adw.ResponseAppearance.DESTRUCTIVE)
|
||||||
|
dialog.set_default_response("cancel")
|
||||||
|
dialog.set_close_response("cancel")
|
||||||
|
|
||||||
|
dialog.connect("response", self.on_delete_response)
|
||||||
|
|
||||||
|
dialog.set_transient_for(self.win)
|
||||||
|
dialog.present()
|
||||||
|
|
||||||
|
def on_delete_response(self, _widget, response):
|
||||||
|
if response == "delete":
|
||||||
|
self.app.clear_all_chats()
|
||||||
|
|
||||||
|
toast = Adw.Toast()
|
||||||
|
toast.set_title(_("All chats cleared!"))
|
||||||
|
self.add_toast(toast)
|
||||||
|
|
||||||
@Gtk.Template.Callback()
|
@Gtk.Template.Callback()
|
||||||
def on_bot_entry_apply(self, user_data, *args):
|
def on_bot_entry_apply(self, user_data, *args):
|
||||||
|
|
Loading…
Reference in a new issue