diff --git a/i18n/en/cosmic_files.ftl b/i18n/en/cosmic_files.ftl index 1f71d75..6435d7a 100644 --- a/i18n/en/cosmic_files.ftl +++ b/i18n/en/cosmic_files.ftl @@ -247,6 +247,7 @@ calculating = Calculating... ## Settings settings = Settings +single-click = Single click to open ### Appearance appearance = Appearance diff --git a/src/app.rs b/src/app.rs index 7589eea..0587e37 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1557,6 +1557,8 @@ impl App { } fn settings(&self) -> Element { + let tab_config = self.config.tab; + // TODO: Should dialog be updated here too? widget::settings::view_column(vec![ widget::settings::section() @@ -1595,6 +1597,20 @@ impl App { Message::SetTypeToSearch, )) .into(), + widget::settings::section() + .title(fl!("other")) + .add({ + widget::settings::item::builder(fl!("single-click")).toggler( + tab_config.single_click, + move |single_click| { + Message::TabConfig(TabConfig { + single_click, + ..tab_config + }) + }, + ) + }) + .into(), ]) .into() } diff --git a/src/config.rs b/src/config.rs index 7688933..959c35a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -209,6 +209,8 @@ pub struct TabConfig { /// 24 hour clock; this is neither serialized nor deserialized because we use the user's global /// preference rather than save it pub military_time: bool, + /// Single click to open + pub single_click: bool, } impl Default for TabConfig { @@ -219,6 +221,7 @@ impl Default for TabConfig { show_hidden: false, icon_sizes: IconSizes::default(), military_time: military_time_enabled(), + single_click: false, } } } diff --git a/src/tab.rs b/src/tab.rs index 9aca631..83c771f 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -2478,6 +2478,21 @@ impl Tab { if let Some(ref mut items) = self.items_opt { for (i, item) in items.iter_mut().enumerate() { if Some(i) == click_i_opt { + // Single click to open. + if !mod_ctrl && self.config.single_click { + if let Some(location) = &item.location_opt { + if item.metadata.is_dir() { + cd = Some(location.clone()); + } else if let Some(path) = location.path_opt() { + commands.push(Command::OpenFile(path.to_path_buf())); + } else { + log::warn!("no path for item {:?}", item); + } + } else { + log::warn!("no location for item {:?}", item); + } + } + // Filter out selection if it does not match dialog kind if let Mode::Dialog(dialog) = &self.mode { let item_is_dir = item.metadata.is_dir();