Add 'Single click to open' settings toggle
This commit is contained in:
parent
fac5a25a3f
commit
20e571efab
4 changed files with 35 additions and 0 deletions
|
|
@ -247,6 +247,7 @@ calculating = Calculating...
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
settings = Settings
|
settings = Settings
|
||||||
|
single-click = Single click to open
|
||||||
|
|
||||||
### Appearance
|
### Appearance
|
||||||
appearance = Appearance
|
appearance = Appearance
|
||||||
|
|
|
||||||
16
src/app.rs
16
src/app.rs
|
|
@ -1557,6 +1557,8 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn settings(&self) -> Element<Message> {
|
fn settings(&self) -> Element<Message> {
|
||||||
|
let tab_config = self.config.tab;
|
||||||
|
|
||||||
// TODO: Should dialog be updated here too?
|
// TODO: Should dialog be updated here too?
|
||||||
widget::settings::view_column(vec![
|
widget::settings::view_column(vec![
|
||||||
widget::settings::section()
|
widget::settings::section()
|
||||||
|
|
@ -1595,6 +1597,20 @@ impl App {
|
||||||
Message::SetTypeToSearch,
|
Message::SetTypeToSearch,
|
||||||
))
|
))
|
||||||
.into(),
|
.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()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,8 @@ pub struct TabConfig {
|
||||||
/// 24 hour clock; this is neither serialized nor deserialized because we use the user's global
|
/// 24 hour clock; this is neither serialized nor deserialized because we use the user's global
|
||||||
/// preference rather than save it
|
/// preference rather than save it
|
||||||
pub military_time: bool,
|
pub military_time: bool,
|
||||||
|
/// Single click to open
|
||||||
|
pub single_click: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TabConfig {
|
impl Default for TabConfig {
|
||||||
|
|
@ -219,6 +221,7 @@ impl Default for TabConfig {
|
||||||
show_hidden: false,
|
show_hidden: false,
|
||||||
icon_sizes: IconSizes::default(),
|
icon_sizes: IconSizes::default(),
|
||||||
military_time: military_time_enabled(),
|
military_time: military_time_enabled(),
|
||||||
|
single_click: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
src/tab.rs
15
src/tab.rs
|
|
@ -2478,6 +2478,21 @@ impl Tab {
|
||||||
if let Some(ref mut items) = self.items_opt {
|
if let Some(ref mut items) = self.items_opt {
|
||||||
for (i, item) in items.iter_mut().enumerate() {
|
for (i, item) in items.iter_mut().enumerate() {
|
||||||
if Some(i) == click_i_opt {
|
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
|
// Filter out selection if it does not match dialog kind
|
||||||
if let Mode::Dialog(dialog) = &self.mode {
|
if let Mode::Dialog(dialog) = &self.mode {
|
||||||
let item_is_dir = item.metadata.is_dir();
|
let item_is_dir = item.metadata.is_dir();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue