Preview and gallery mode changes, part of #540

This commit is contained in:
Jeremy Soller 2024-10-02 13:23:41 -06:00
parent 18c1301820
commit 9b8844a884
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
5 changed files with 12 additions and 4 deletions

View file

@ -208,7 +208,6 @@ file = File
new-tab = New tab new-tab = New tab
new-window = New window new-window = New window
rename = Rename... rename = Rename...
menu-show-details = Show details...
close-tab = Close tab close-tab = Close tab
quit = Quit quit = Quit
@ -228,6 +227,7 @@ grid-view = Grid view
list-view = List view list-view = List view
show-hidden-files = Show hidden files show-hidden-files = Show hidden files
list-directories-first = List directories first list-directories-first = List directories first
gallery-preview = Gallery preview
menu-settings = Settings... menu-settings = Settings...
menu-about = About COSMIC Files... menu-about = About COSMIC Files...

View file

@ -95,6 +95,7 @@ pub enum Action {
EditHistory, EditHistory,
EditLocation, EditLocation,
ExtractHere, ExtractHere,
Gallery,
HistoryNext, HistoryNext,
HistoryPrevious, HistoryPrevious,
ItemDown, ItemDown,
@ -147,6 +148,7 @@ impl Action {
Action::EditHistory => Message::ToggleContextPage(ContextPage::EditHistory), Action::EditHistory => Message::ToggleContextPage(ContextPage::EditHistory),
Action::EditLocation => Message::EditLocation(entity_opt), Action::EditLocation => Message::EditLocation(entity_opt),
Action::ExtractHere => Message::ExtractHere(entity_opt), Action::ExtractHere => Message::ExtractHere(entity_opt),
Action::Gallery => Message::TabMessage(entity_opt, tab::Message::GalleryToggle),
Action::HistoryNext => Message::TabMessage(entity_opt, tab::Message::GoNext), Action::HistoryNext => Message::TabMessage(entity_opt, tab::Message::GoNext),
Action::HistoryPrevious => Message::TabMessage(entity_opt, tab::Message::GoPrevious), Action::HistoryPrevious => Message::TabMessage(entity_opt, tab::Message::GoPrevious),
Action::ItemDown => Message::TabMessage(entity_opt, tab::Message::ItemDown), Action::ItemDown => Message::TabMessage(entity_opt, tab::Message::ItemDown),

View file

@ -27,6 +27,7 @@ pub fn key_binds() -> HashMap<KeyBind, Action> {
bind!([Ctrl], Key::Character("c".into()), Copy); bind!([Ctrl], Key::Character("c".into()), Copy);
bind!([Ctrl], Key::Character("x".into()), Cut); bind!([Ctrl], Key::Character("x".into()), Cut);
bind!([Ctrl], Key::Character("l".into()), EditLocation); bind!([Ctrl], Key::Character("l".into()), EditLocation);
bind!([], Key::Named(Named::Space), Gallery);
bind!([Alt], Key::Named(Named::ArrowRight), HistoryNext); bind!([Alt], Key::Named(Named::ArrowRight), HistoryNext);
bind!([Alt], Key::Named(Named::ArrowLeft), HistoryPrevious); bind!([Alt], Key::Named(Named::ArrowLeft), HistoryPrevious);
bind!([], Key::Named(Named::Backspace), HistoryPrevious); bind!([], Key::Named(Named::Backspace), HistoryPrevious);
@ -47,7 +48,7 @@ pub fn key_binds() -> HashMap<KeyBind, Action> {
bind!([Ctrl], Key::Named(Named::Enter), OpenInNewTab); bind!([Ctrl], Key::Named(Named::Enter), OpenInNewTab);
bind!([Shift], Key::Named(Named::Enter), OpenInNewWindow); bind!([Shift], Key::Named(Named::Enter), OpenInNewWindow);
bind!([Ctrl], Key::Character("v".into()), Paste); bind!([Ctrl], Key::Character("v".into()), Paste);
bind!([], Key::Named(Named::Space), Preview); bind!([Ctrl], Key::Named(Named::Space), Preview);
bind!([], Key::Named(Named::F2), Rename); bind!([], Key::Named(Named::F2), Rename);
bind!([Ctrl], Key::Character("f".into()), SearchActivate); bind!([Ctrl], Key::Character("f".into()), SearchActivate);
bind!([Ctrl], Key::Character("a".into()), SelectAll); bind!([Ctrl], Key::Character("a".into()), SelectAll);

View file

@ -412,8 +412,6 @@ pub fn menu_bar<'a>(
menu::Item::Divider, menu::Item::Divider,
menu_button_optional(fl!("rename"), Action::Rename, selected > 0), menu_button_optional(fl!("rename"), Action::Rename, selected > 0),
menu::Item::Divider, menu::Item::Divider,
menu_button_optional(fl!("menu-show-details"), Action::Preview, selected > 0),
menu::Item::Divider,
menu_button_optional(fl!("add-to-sidebar"), Action::AddToSidebar, selected > 0), menu_button_optional(fl!("add-to-sidebar"), Action::AddToSidebar, selected > 0),
menu::Item::Divider, menu::Item::Divider,
menu_button_optional(fl!("move-to-trash"), Action::MoveToTrash, selected > 0), menu_button_optional(fl!("move-to-trash"), Action::MoveToTrash, selected > 0),
@ -467,6 +465,9 @@ pub fn menu_bar<'a>(
tab_opt.map_or(false, |tab| tab.config.folders_first), tab_opt.map_or(false, |tab| tab.config.folders_first),
Action::ToggleFoldersFirst, Action::ToggleFoldersFirst,
), ),
menu_button_optional(fl!("show-details"), Action::Preview, selected > 0),
menu::Item::Divider,
menu_button_optional(fl!("gallery-preview"), Action::Gallery, selected > 0),
menu::Item::Divider, menu::Item::Divider,
menu::Item::Button(fl!("menu-settings"), Action::Settings), menu::Item::Button(fl!("menu-settings"), Action::Settings),
menu::Item::Divider, menu::Item::Divider,

View file

@ -850,6 +850,7 @@ pub enum Message {
Gallery(bool), Gallery(bool),
GalleryPrevious, GalleryPrevious,
GalleryNext, GalleryNext,
GalleryToggle,
GoNext, GoNext,
GoPrevious, GoPrevious,
ItemDown, ItemDown,
@ -2071,6 +2072,9 @@ impl Tab {
commands.push(Command::Iced(widget::button::focus(id))); commands.push(Command::Iced(widget::button::focus(id)));
} }
} }
Message::GalleryToggle => {
self.gallery = !self.gallery;
}
Message::GoNext => { Message::GoNext => {
if let Some(history_i) = self.history_i.checked_add(1) { if let Some(history_i) = self.history_i.checked_add(1) {
if let Some(location) = self.history.get(history_i) { if let Some(location) = self.history.get(history_i) {