Small TabConfig clean ups

* Rename `config::Tab` to `TabConfig`
* Use the loaded tab config instead of the default (oops)
This commit is contained in:
Josh Megnauth 2024-02-11 01:16:51 -05:00 committed by Jeremy Soller
parent bc5b46d552
commit e697e96afe
4 changed files with 16 additions and 12 deletions

View file

@ -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<Message> {
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::*;

View file

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

View file

@ -25,7 +25,7 @@ use std::{
};
use crate::{
config::Tab as TabConfig,
config::TabConfig,
fl, home_dir,
tab::{self, Location, Tab},
};

View file

@ -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.