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

View file

@ -95,6 +95,7 @@ pub enum Action {
EditHistory,
EditLocation,
ExtractHere,
Gallery,
HistoryNext,
HistoryPrevious,
ItemDown,
@ -147,6 +148,7 @@ impl Action {
Action::EditHistory => Message::ToggleContextPage(ContextPage::EditHistory),
Action::EditLocation => Message::EditLocation(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::HistoryPrevious => Message::TabMessage(entity_opt, tab::Message::GoPrevious),
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("x".into()), Cut);
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::ArrowLeft), 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!([Shift], Key::Named(Named::Enter), OpenInNewWindow);
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!([Ctrl], Key::Character("f".into()), SearchActivate);
bind!([Ctrl], Key::Character("a".into()), SelectAll);

View file

@ -412,8 +412,6 @@ pub fn menu_bar<'a>(
menu::Item::Divider,
menu_button_optional(fl!("rename"), Action::Rename, selected > 0),
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::Item::Divider,
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),
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::Button(fl!("menu-settings"), Action::Settings),
menu::Item::Divider,

View file

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