Merge pull request #683 from CaelusV/single-click
Add 'Single click to open' settings toggle
This commit is contained in:
commit
06fd35db76
4 changed files with 35 additions and 0 deletions
|
|
@ -249,6 +249,7 @@ calculating = Calculating...
|
|||
|
||||
## Settings
|
||||
settings = Settings
|
||||
single-click = Single click to open
|
||||
|
||||
### Appearance
|
||||
appearance = Appearance
|
||||
|
|
|
|||
16
src/app.rs
16
src/app.rs
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
src/tab.rs
15
src/tab.rs
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue