From 2a0834d888cd5f6662a7715d38cb281f6a4b0855 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Sun, 9 Aug 2026 21:16:55 +0200 Subject: [PATCH] add Show Trash menu item --- application/note/src/main.rs | 4 ++++ application/note/src/notebook.rs | 2 +- application/note/src/window.rs | 29 ++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/application/note/src/main.rs b/application/note/src/main.rs index fc5a96e..d97e6ff 100644 --- a/application/note/src/main.rs +++ b/application/note/src/main.rs @@ -147,6 +147,8 @@ fn create_menubar(app: &AppContext) { menu.item("Rename").action("note_rename").create(); menu.item("Delete").action("note_delete").create(); menu.item("Edit Title").action("note_edit_title").create(); + menu.separator(); + menu.item("Show Trash").action("show_trash").create(); }); } @@ -178,6 +180,8 @@ fn create_toolbar(app: &AppContext) { menu.item("Rename").action("note_rename").create(); menu.item("Delete").action("delete_note").create(); menu.item("Edit Title").action("note_edit_title").create(); + menu.separator(); + menu.item("Show Trash").action("show_trash").create(); }); } diff --git a/application/note/src/notebook.rs b/application/note/src/notebook.rs index e83bd18..5c84162 100644 --- a/application/note/src/notebook.rs +++ b/application/note/src/notebook.rs @@ -351,7 +351,7 @@ impl Notebook { self.select_note_from(NoteSelectFrom::NavigationItem(nav.clone())); } - + pub fn update_note_title(&mut self, update: &NoteTitleUpdate) { // TODO: use find_note // Find the note in the list (or add it if it doesn't exist yet) diff --git a/application/note/src/window.rs b/application/note/src/window.rs index 44c824c..7e4d4d6 100644 --- a/application/note/src/window.rs +++ b/application/note/src/window.rs @@ -48,6 +48,7 @@ pub struct MainWindow { selected_notebook: Option>, groups: Vec, + trash: Option, #[bind] notebooks: UiSourceList @@ -64,6 +65,7 @@ impl MainWindow { navigation: Navigation::default(), selected_notebook: None, groups: Vec::new(), + trash: None, notebooks: UiSourceList::default() } } @@ -108,6 +110,30 @@ impl MainWindow { } } + #[action] + pub fn show_trash(&mut self, _event: &ActionEvent) { + let Some(mut obj) = self.obj.get_object() else { + return; + }; + + if let Some(trash) = &mut self.trash { + let nav = NavigationItem { collection_id: trash.data.collection_id, ..Default::default() }; + // detach current notebook + if let Some(current) = &self.selected_notebook { + current.ctx.call_action("save"); + obj.ctx.detach(current); + } + + let notebook_doc = trash.get_doc(&self.backend); + obj.splitview_set_visible(0, true); + obj.ctx.attach(¬ebook_doc); + self.selected_notebook = Some(notebook_doc); + //e.obj.splitview_set_visible(0, !nav.note_maximized); + + self.navigation.push(nav); + } + } + pub fn do_nav(&mut self, direction: NavDirection) -> Option<()> { let nav = match direction { NavDirection::Forward => self.navigation.go_forward(), @@ -168,7 +194,8 @@ impl MainWindow { for elm in nodes.iter() { if elm.collection.kind == CollectionType::Trash { - // TODO: add to trash list + let trash = NotebookItem::from_model(elm.collection.clone()); + self.trash = Some(trash); continue; } -- 2.52.0