Merge pull request #683 from CaelusV/single-click

Add 'Single click to open' settings toggle
This commit is contained in:
Jeremy Soller 2025-03-19 16:25:37 +00:00 committed by GitHub
commit 06fd35db76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 0 deletions

View file

@ -249,6 +249,7 @@ calculating = Calculating...
## Settings
settings = Settings
single-click = Single click to open
### Appearance
appearance = Appearance

View file

@ -1566,6 +1566,8 @@ impl App {
}
fn settings(&self) -> Element<Message> {
let tab_config = self.config.tab;
// TODO: Should dialog be updated here too?
widget::settings::view_column(vec![
widget::settings::section()
@ -1604,6 +1606,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()
}

View file

@ -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,
}
}
}

View file

@ -2481,6 +2481,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();