Add context menu items for sorting
This commit is contained in:
parent
e22c74d721
commit
02417a6f2f
3 changed files with 50 additions and 1 deletions
|
|
@ -82,6 +82,9 @@ new-folder = New folder
|
|||
open-in-terminal = Open in terminal
|
||||
move-to-trash = Move to trash
|
||||
restore-from-trash = Restore from trash
|
||||
sort-by-name = Sort by name
|
||||
sort-by-modified = Sort by modified
|
||||
sort-by-size = Sort by size
|
||||
|
||||
# Menu
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ pub enum Action {
|
|||
TabViewGrid,
|
||||
TabViewList,
|
||||
ToggleShowHidden,
|
||||
ToggleSort(HeadingOptions),
|
||||
WindowClose,
|
||||
WindowNew,
|
||||
}
|
||||
|
|
@ -120,6 +121,7 @@ impl Action {
|
|||
Message::TabMessage(entity_opt, tab::Message::View(tab::View::List))
|
||||
}
|
||||
Action::ToggleShowHidden => Message::TabMessage(None, tab::Message::ToggleShowHidden),
|
||||
Action::ToggleSort(sort) => Message::TabMessage(None, tab::Message::ToggleSort(sort)),
|
||||
Action::WindowClose => Message::WindowClose,
|
||||
Action::WindowNew => Message::WindowNew,
|
||||
}
|
||||
|
|
|
|||
46
src/menu.rs
46
src/menu.rs
|
|
@ -16,7 +16,7 @@ use crate::{
|
|||
app::{Action, Message},
|
||||
fl,
|
||||
key_bind::KeyBind,
|
||||
tab::{self, Location, Tab},
|
||||
tab::{self, HeadingOptions, Location, Tab},
|
||||
};
|
||||
|
||||
macro_rules! menu_button {
|
||||
|
|
@ -102,6 +102,28 @@ pub fn context_menu<'a>(
|
|||
children.push(horizontal_rule(1).into());
|
||||
children.push(menu_item(fl!("select-all"), Action::SelectAll).into());
|
||||
children.push(menu_item(fl!("paste"), Action::Paste).into());
|
||||
children.push(horizontal_rule(1).into());
|
||||
children.push(
|
||||
menu_item(
|
||||
fl!("sort-by-name"),
|
||||
Action::ToggleSort(HeadingOptions::Name),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
children.push(
|
||||
menu_item(
|
||||
fl!("sort-by-modified"),
|
||||
Action::ToggleSort(HeadingOptions::Modified),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
children.push(
|
||||
menu_item(
|
||||
fl!("sort-by-size"),
|
||||
Action::ToggleSort(HeadingOptions::Size),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Location::Trash => {
|
||||
|
|
@ -113,6 +135,28 @@ pub fn context_menu<'a>(
|
|||
children
|
||||
.push(menu_item(fl!("restore-from-trash"), Action::RestoreFromTrash).into());
|
||||
}
|
||||
children.push(horizontal_rule(1).into());
|
||||
children.push(
|
||||
menu_item(
|
||||
fl!("sort-by-name"),
|
||||
Action::ToggleSort(HeadingOptions::Name),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
children.push(
|
||||
menu_item(
|
||||
fl!("sort-by-modified"),
|
||||
Action::ToggleSort(HeadingOptions::Modified),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
children.push(
|
||||
menu_item(
|
||||
fl!("sort-by-size"),
|
||||
Action::ToggleSort(HeadingOptions::Size),
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue