feat: search in Recents and Trash

This commit is contained in:
Jason Rodney Hansen 2026-02-14 11:56:52 -07:00
parent 49e3d95e7a
commit bba95c3fc0
4 changed files with 459 additions and 275 deletions

View file

@ -22,7 +22,7 @@ use crate::{
app::{Action, Message},
config::Config,
fl,
tab::{self, HeadingOptions, Location, LocationMenuAction, Tab},
tab::{self, HeadingOptions, Location, LocationMenuAction, SearchLocation, Tab},
};
static MENU_ID: LazyLock<cosmic::widget::Id> =
@ -138,7 +138,9 @@ pub fn context_menu<'a>(
selected_dir += 1;
}
match &item.location_opt {
Some(Location::Trash) => selected_trash_only = true,
Some(Location::Trash) | Some(Location::Search(SearchLocation::Trash, ..)) => {
selected_trash_only = true
}
Some(Location::Path(path)) => {
if selected == 1
&& path.extension().and_then(|s| s.to_str()) == Some("desktop")
@ -174,7 +176,8 @@ pub fn context_menu<'a>(
tab::Mode::App | tab::Mode::Desktop,
Location::Desktop(..)
| Location::Path(..)
| Location::Search(..)
| Location::Search(SearchLocation::Path(..), ..)
| Location::Search(SearchLocation::Recents, ..)
| Location::Recents
| Location::Network(_, _, Some(_)),
) => {
@ -212,7 +215,7 @@ pub fn context_menu<'a>(
.push(menu_item(fl!("open-in-terminal"), Action::OpenTerminal).into());
}
}
if matches!(tab.location, Location::Search(..) | Location::Recents) {
if tab.location.is_recents() {
children.push(
menu_item(fl!("open-item-location"), Action::OpenItemLocation).into(),
);
@ -255,7 +258,7 @@ pub fn context_menu<'a>(
children.push(menu_item(fl!("add-to-sidebar"), Action::AddToSidebar).into());
}
children.push(divider::horizontal::light().into());
if matches!(tab.location, Location::Recents) {
if tab.location.is_recents() {
children.push(
menu_item(fl!("remove-from-recents"), Action::RemoveFromRecents).into(),
);
@ -322,7 +325,8 @@ pub fn context_menu<'a>(
tab::Mode::Dialog(dialog_kind),
Location::Desktop(..)
| Location::Path(..)
| Location::Search(..)
| Location::Search(SearchLocation::Path(..), ..)
| Location::Search(SearchLocation::Recents, ..)
| Location::Recents
| Location::Network(_, _, Some(_)),
) => {
@ -330,7 +334,7 @@ pub fn context_menu<'a>(
if selected_dir == 1 && selected == 1 || selected_dir == 0 {
children.push(menu_item(fl!("open"), Action::Open).into());
}
if matches!(tab.location, Location::Search(..) | Location::Recents) {
if matches!(tab.location, Location::Search(..)) || tab.location.is_recents() {
children.push(
menu_item(fl!("open-item-location"), Action::OpenItemLocation).into(),
);
@ -369,7 +373,7 @@ pub fn context_menu<'a>(
children.push(sort_item(fl!("sort-by-size"), HeadingOptions::Size));
}
}
(_, Location::Trash) => {
(_, Location::Trash | Location::Search(SearchLocation::Trash, ..)) => {
if tab.mode.multiple() {
children.push(menu_item(fl!("select-all"), Action::SelectAll).into());
}
@ -428,7 +432,7 @@ pub fn dialog_menu(
Action::SetSort(sort, dir),
)
};
let in_trash = tab.location == Location::Trash;
let in_trash = tab.location.is_trash();
let mut selected_gallery = 0;
if let Some(items) = tab.items_opt() {
@ -578,7 +582,7 @@ pub fn menu_bar<'a>(
Action::SetSort(sort, dir),
)
};
let in_trash = tab_opt.is_some_and(|tab| tab.location == Location::Trash);
let in_trash = tab_opt.is_some_and(|tab| tab.location.is_trash());
let mut selected_dir = 0;
let mut selected = 0;