diff --git a/src/app.rs b/src/app.rs index 28933a4..2a2100d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -26,7 +26,7 @@ use std::{ }; use crate::{ - config::{AppTheme, Config, Tab as TabConfig, CONFIG_VERSION}, + config::{AppTheme, Config, CONFIG_VERSION}, fl, home_dir, key_bind::{key_binds, KeyBind}, menu, mouse_area, @@ -188,7 +188,7 @@ pub struct App { impl App { fn open_tab(&mut self, location: Location) -> Command { - let tab = Tab::new(location.clone(), TabConfig::default()); + let tab = Tab::new(location.clone(), self.config.tab.clone()); let entity = self .tab_model .insert() @@ -1086,7 +1086,7 @@ pub(crate) mod test_utils { use log::{debug, trace}; use tempfile::{tempdir, TempDir}; - use crate::tab::Item; + use crate::{config::TabConfig, tab::Item}; use super::*; diff --git a/src/config.rs b/src/config.rs index 7e751d5..4ea8000 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,22 +28,26 @@ impl AppTheme { #[derive(Clone, CosmicConfigEntry, Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct Config { pub app_theme: AppTheme, - pub tab: Tab, + pub tab: TabConfig, } impl Default for Config { fn default() -> Self { Self { app_theme: AppTheme::System, - tab: Tab::default(), + tab: TabConfig::default(), } } } -/// Per tab config +/// Global and local [`crate::tab::Tab`] config. +/// +/// [`TabConfig`] contains options that are passed to each instance of [`crate::tab::Tab`]. +/// These options are set globally through the main config, but each tab may change options +/// locally. Local changes aren't saved to the main config. #[derive(Clone, Debug, Eq, PartialEq, CosmicConfigEntry, Deserialize, Serialize)] -pub struct Tab { - /// Show hidden files +pub struct TabConfig { + /// Show hidden files and folders pub show_hidden: bool, // TODO: Other possible options // pub sort_by: fn(&PathBuf, &PathBuf) -> Ordering, @@ -53,7 +57,7 @@ pub struct Tab { // icon_size_grid: u16, } -impl Default for Tab { +impl Default for TabConfig { fn default() -> Self { Self { show_hidden: false } } diff --git a/src/dialog.rs b/src/dialog.rs index 3e265ff..e3f0f90 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -25,7 +25,7 @@ use std::{ }; use crate::{ - config::Tab as TabConfig, + config::TabConfig, fl, home_dir, tab::{self, Location, Tab}, }; diff --git a/src/tab.rs b/src/tab.rs index af0c2c5..71eb060 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -23,7 +23,7 @@ use std::{ time::{Duration, Instant}, }; -use crate::{config::Tab as TabConfig, fl, home_dir, mime_icon::mime_icon}; +use crate::{config::TabConfig, fl, home_dir, mime_icon::mime_icon}; const DOUBLE_CLICK_DURATION: Duration = Duration::from_millis(500); //TODO: configurable @@ -1068,7 +1068,7 @@ mod tests { read_dir_sorted, simple_fs, sort_files, tab_click_new, NAME_LEN, NUM_DIRS, NUM_FILES, NUM_HIDDEN, NUM_NESTED, }, - config::Tab as TabConfig, + config::TabConfig, }; // Boilerplate for tab tests. Checks if simulated clicks selected items.