feat: add clear all chats
Some checks failed
Build / Flatpak (x86_64) (push) Failing after 4m11s

This commit is contained in:
0xMRTT 2023-08-02 16:58:04 +02:00
parent 1b1ce144d3
commit 33257d6089
3 changed files with 33 additions and 0 deletions

View File

@ -273,6 +273,10 @@ class BavarderApplication(Adw.Application):
def check_network(self):
return False
def clear_all_chats(self):
self.data["chats"] = []
self.win.load_threads()
def main(version):
"""The application's entry point."""
app = BavarderApplication()

View File

@ -8,6 +8,7 @@ template $Preferences : Adw.PreferencesWindow {
modal: true;
Adw.PreferencesPage general_page {
title: _("Models");
Adw.PreferencesGroup provider_group {
title: _("Providers");
@ -15,7 +16,26 @@ template $Preferences : Adw.PreferencesWindow {
Adw.PreferencesGroup model_group {
title: _("Models");
}
}
Adw.PreferencesPage {
title: _("Preferences");
Adw.PreferencesGroup miscellaneous_group {
title: _("Miscellaneous");
Adw.ActionRow {
title: _("Clear all chats");
Button clear_all_chats_button {
valign: center;
label: _("Clear");
tooltip-text: _("This will clear all chats from the database.");
clicked => $clear_all_chats_clicked();
styles ["destructive-action"]
}
}
}
}
}

View File

@ -14,6 +14,7 @@ class PreferencesWindow(Adw.PreferencesWindow):
provider_group = Gtk.Template.Child()
general_page = Gtk.Template.Child()
model_group = Gtk.Template.Child()
miscellaneous_group = Gtk.Template.Child()
def __init__(self, parent, **kwargs):
super().__init__(**kwargs)
@ -59,3 +60,11 @@ class PreferencesWindow(Adw.PreferencesWindow):
self.model_group.add(self.no_models_available)
self.general_page.add(self.model_group)
@Gtk.Template.Callback()
def clear_all_chats_clicked(self, widget, *args):
self.app.clear_all_chats()
toast = Adw.Toast()
toast.set_title(_("All chats cleared!"))
self.add_toast(toast)