Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "EdenExplorer"
version = "0.3.0"
version = "0.3.1"
edition = "2024"
build = "src/build.rs"

Expand Down
43 changes: 41 additions & 2 deletions src/core/indexer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::core::fs::MY_PC_PATH;
use crate::gui::theme::ThemePalette;
use crate::gui::theme::{ThemePalette, get_default_palette};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

Expand Down Expand Up @@ -160,9 +160,17 @@ pub fn save_app_settings(
pub fn load_theme_settings() -> Option<(ThemePalette, ThemePalette)> {
let path = theme_cache_path()?;
let data = std::fs::read(path).ok()?;

match bincode::deserialize::<ThemeSettingsSnapshot>(&data) {
Ok(snapshot) => Some((snapshot.light, snapshot.dark)),
Err(_) => None,
Err(e) => {
eprintln!(
"Theme deserialization failed (likely due to theme variable changes): {}. Resetting to defaults.",
e
);
reset_theme_to_defaults();
None
}
}
}

Expand All @@ -180,3 +188,34 @@ pub fn save_theme_settings(light: &ThemePalette, dark: &ThemePalette) {
let _ = std::fs::write(path, data);
}
}

/// Resets theme settings to defaults by deleting the corrupted theme file
fn reset_theme_to_defaults() {
if let Some(path) = theme_cache_path() {
// Remove the corrupted theme file
if let Err(e) = std::fs::remove_file(&path) {
eprintln!("Failed to remove corrupted theme file: {}", e);
} else {
eprintln!("Corrupted theme file removed. Will use defaults on next startup.");
}

// Save fresh default themes
let light_default = get_default_palette(crate::gui::theme::ThemeMode::Light);
let dark_default = get_default_palette(crate::gui::theme::ThemeMode::Dark);
save_theme_settings(&light_default, &dark_default);
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_theme_reset_functionality() {
// Test that reset_theme_to_defaults doesn't panic
// In a real scenario, this would be tested with actual file system operations
// For now, we just verify the function exists and can be called
let path = theme_cache_path();
assert!(path.is_some() || path.is_none()); // Basic sanity check
}
}
39 changes: 15 additions & 24 deletions src/gui/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,20 @@ pub struct ThemePalette {
pub primary_active: Color32,
pub primary_subtle: Color32,
pub secondary: Color32,
pub text_normal: Color32,
pub text_header_section: Color32,

// 🧱 Application surfaces
pub application_bg_color: Color32,
pub modal_background_effect_color: Color32,

// 🎯 Selection / box selection
pub box_selection_stroke: Color32,
pub box_selection_fill: Color32,

// 🎯 Icons & text
pub icon_color: Color32,
pub icon_windows: Color32,
pub icon_colored_hover: Color32,
pub item_viewer_row_text_selected: Color32,
pub item_viewer_row_text_normal: Color32,
pub item_viewer_col_header_text: Color32,
pub tooltip_text_color: Color32,
pub tab_text_selected: Color32,
pub tab_text_normal: Color32,

// 🎯 Rows / list items
pub row_selected_bg: Color32,
Expand All @@ -57,6 +52,8 @@ pub struct ThemePalette {

// 🎯 Tab button colors
pub tab_close_hover: Color32,
pub tab_close_active: Color32,
pub tab_close_normal: Color32,
pub tab_add_hover: Color32,

// 🎯 Drive usage colors
Expand Down Expand Up @@ -106,25 +103,20 @@ pub static DEFAULT_PALETTE_DARK: LazyLock<ThemePalette> = LazyLock::new(|| {
primary_active: Color32::from_rgb(70, 55, 110),
primary_subtle: Color32::from_rgba_unmultiplied(95, 75, 135, 60),
secondary: Color32::from_rgb(255, 255, 255),
text_normal: Color32::from_rgb(160, 170, 180),
text_header_section: Color32::WHITE,

// 🧱 Application surfaces
application_bg_color: Color32::from_rgb(20, 22, 26),
modal_background_effect_color: Color32::from_black_alpha(180),

// 🎯 Selection / box selection
box_selection_stroke: Color32::from_rgba_unmultiplied(95, 75, 135, 60),
box_selection_fill: base,

// 🎯 Icons & text
icon_color: Color32::WHITE,
icon_windows: Color32::WHITE,
icon_colored_hover: Color32::WHITE,
item_viewer_row_text_selected: Color32::WHITE,
item_viewer_row_text_normal: Color32::from_rgb(160, 170, 180),
item_viewer_col_header_text: Color32::WHITE,
tooltip_text_color: Color32::from_rgb(220, 220, 220),
tooltip_text_color: Color32::from_rgb(160, 170, 180),
tab_text_selected: Color32::WHITE,
tab_text_normal: Color32::from_rgb(160, 170, 180),

// 🎯 Rows / list items
row_selected_bg: Color32::from_rgb(70, 78, 86),
Expand All @@ -137,6 +129,8 @@ pub static DEFAULT_PALETTE_DARK: LazyLock<ThemePalette> = LazyLock::new(|| {

// 🎯 Tab button colors
tab_close_hover: Color32::from_rgb(200, 52, 52),
tab_close_active: Color32::WHITE,
tab_close_normal: Color32::from_rgb(160, 170, 180),
tab_add_hover: Color32::from_rgb(54, 168, 82),

// 🎯 Drive usage colors
Expand Down Expand Up @@ -191,26 +185,21 @@ pub static DEFAULT_PALETTE_LIGHT: LazyLock<ThemePalette> = LazyLock::new(|| {
primary_hover: Color32::from_rgba_unmultiplied(110, 85, 160, 90),
primary_active: Color32::from_rgb(140, 120, 200),
primary_subtle: Color32::from_rgba_unmultiplied(110, 85, 160, 40),
secondary: Color32::from_rgb(0, 0, 0),
secondary: Color32::BLACK,
text_normal: Color32::from_rgb(70, 78, 86),
text_header_section: Color32::BLACK,

// 🧱 Application surfaces
application_bg_color: Color32::from_rgb(245, 245, 245),
modal_background_effect_color: Color32::from_black_alpha(180),

// 🎯 Selection / box selection
box_selection_stroke: Color32::from_rgba_unmultiplied(110, 85, 160, 40),
box_selection_fill: base,

// 🎯 Icons & text
icon_color: Color32::from_rgb(40, 40, 40),
icon_windows: Color32::WHITE,
icon_colored_hover: Color32::WHITE,
item_viewer_row_text_selected: Color32::from_rgb(0, 0, 0),
item_viewer_row_text_normal: Color32::from_rgb(70, 78, 86),
item_viewer_col_header_text: Color32::from_rgb(0, 0, 0),
item_viewer_row_text_selected: Color32::BLACK,
tooltip_text_color: Color32::from_rgb(40, 40, 40),
tab_text_selected: Color32::WHITE,
tab_text_normal: Color32::from_rgb(70, 78, 86),

// 🎯 Rows / list items
row_selected_bg: Color32::from_rgb(70, 78, 86),
Expand All @@ -223,6 +212,8 @@ pub static DEFAULT_PALETTE_LIGHT: LazyLock<ThemePalette> = LazyLock::new(|| {

// 🎯 Tab button colors
tab_close_hover: Color32::from_rgb(200, 52, 52),
tab_close_active: Color32::WHITE,
tab_close_normal: Color32::from_rgb(40, 40, 40),
tab_add_hover: Color32::from_rgb(54, 168, 82),

// 🎯 Drive usage colors
Expand Down
6 changes: 3 additions & 3 deletions src/gui/windows/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn draw_about_window(ctx: &egui::Context, settings: &mut AboutWindow, palett
ui.set_width(ui.available_width());
let font_id = FontId::new(palette.text_size, egui::FontFamily::Proportional);

ui.label(egui::RichText::new("EdenExplorer is a next-generation, blazing-fast fully open-source file explorer built for Windows 11+ using Rust and egui. Designed from the ground up for performance, efficiency, and modern workflows, EdenExplorer is the best FOSS alternative to the default Windows File Explorer.").font(font_id).size(palette.text_size).color(palette.item_viewer_row_text_normal));
ui.label(egui::RichText::new("EdenExplorer is a next-generation, blazing-fast fully open-source file explorer built for Windows 11+ using Rust and egui. Designed from the ground up for performance, efficiency, and modern workflows, EdenExplorer is the best FOSS alternative to the default Windows File Explorer.").font(font_id).size(palette.text_size).color(palette.text_normal));
ui.add_space(8.0);
ui.heading("Cargo Dependencies");
egui::ScrollArea::vertical()
Expand All @@ -61,8 +61,8 @@ pub fn draw_about_window(ctx: &egui::Context, settings: &mut AboutWindow, palett
.striped(true)
.show(ui, |ui| {
// Header
ui.label(egui::RichText::new("Dependency").strong().color(palette.item_viewer_row_text_normal));
ui.label(egui::RichText::new("Version").strong().color(palette.item_viewer_row_text_normal));
ui.label(egui::RichText::new("Dependency").strong().color(palette.text_normal));
ui.label(egui::RichText::new("Version").strong().color(palette.text_normal));
ui.end_row();
let mut style = (*ui.ctx().style()).clone();
style.text_styles = [
Expand Down
14 changes: 7 additions & 7 deletions src/gui/windows/containers/itemviewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ fn get_row_color(
if is_multi_selected {
palette.item_viewer_row_text_selected
} else {
palette.item_viewer_row_text_normal
palette.text_normal
}
}

Expand Down Expand Up @@ -1432,7 +1432,7 @@ fn draw_item_viewer_header(
egui::RichText::new(format!("{label} {arrow}").trim_end())
.font(font_id.clone())
.size(palette.text_size)
.color(palette.item_viewer_col_header_text),
.color(palette.text_header_section),
)
.selectable(false)
.sense(egui::Sense::click()),
Expand All @@ -1459,7 +1459,7 @@ fn draw_item_viewer_header(
egui::RichText::new(format!("{label} {arrow}").trim_end())
.font(font_id.clone())
.size(palette.text_size)
.color(palette.item_viewer_col_header_text),
.color(palette.text_header_section),
)
.selectable(false)
.sense(egui::Sense::click()),
Expand All @@ -1486,7 +1486,7 @@ fn draw_item_viewer_header(
egui::RichText::new(format!("{label} {arrow}").trim_end())
.font(font_id.clone())
.size(palette.text_size)
.color(palette.item_viewer_col_header_text),
.color(palette.text_header_section),
)
.selectable(false)
.sense(egui::Sense::click()),
Expand All @@ -1506,7 +1506,7 @@ fn draw_item_viewer_header(
egui::RichText::new(format!("Usage").trim_end())
.font(font_id.clone())
.size(palette.text_size)
.color(palette.item_viewer_col_header_text),
.color(palette.text_header_section),
)
.selectable(false)
.sense(egui::Sense::click()),
Expand All @@ -1530,7 +1530,7 @@ fn draw_item_viewer_header(
egui::RichText::new(format!("{label} {arrow}").trim_end())
.font(font_id.clone())
.size(palette.text_size)
.color(palette.item_viewer_col_header_text),
.color(palette.text_header_section),
)
.selectable(false)
.sense(egui::Sense::click()),
Expand All @@ -1557,7 +1557,7 @@ fn draw_item_viewer_header(
egui::RichText::new(format!("{label} {arrow}").trim_end())
.font(font_id.clone())
.size(palette.text_size)
.color(palette.item_viewer_col_header_text),
.color(palette.text_header_section),
)
.selectable(false)
.sense(egui::Sense::click()),
Expand Down
3 changes: 3 additions & 0 deletions src/gui/windows/containers/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ pub fn draw_sidebar(
ui.add(egui::Label::new(
egui::RichText::new("Places")
.size(palette.text_size)
.color(palette.text_header_section)
.strong(),
));
ui.add_space(8.0);
Expand Down Expand Up @@ -341,6 +342,7 @@ pub fn draw_sidebar(
ui.add(egui::Label::new(
egui::RichText::new("Favorites")
.size(palette.text_size)
.color(palette.text_header_section)
.strong(),
));
ui.add_space(4.0);
Expand Down Expand Up @@ -499,6 +501,7 @@ pub fn draw_sidebar(
ui.add(egui::Label::new(
egui::RichText::new("Storage")
.size(palette.text_size)
.color(palette.text_header_section)
.strong(),
));
ui.add_space(4.0);
Expand Down
25 changes: 17 additions & 8 deletions src/gui/windows/containers/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fn handle_draw_tab_new_allocated(
let label_color = if is_active {
palette.tab_text_selected
} else {
palette.tab_text_normal
palette.text_normal
};

// --- Layout parameters ---
Expand Down Expand Up @@ -200,7 +200,7 @@ fn handle_draw_tab_new_allocated(
);
}

let close_resp = tab_close_button(ui, rect, tab.id, palette);
let close_resp = tab_close_button(ui, rect, tab.id, is_active, palette);
if close_resp.clicked() {
action.close = Some(tab.id);
} else if resp.clicked() {
Expand Down Expand Up @@ -257,6 +257,7 @@ fn tab_close_button(
ui: &mut egui::Ui,
tab_rect: egui::Rect,
tab_id: u64,
is_active: bool,
palette: &ThemePalette,
) -> egui::Response {
let size = egui::vec2(18.0, 18.0);
Expand All @@ -283,8 +284,10 @@ fn tab_close_button(

let color = if hovered {
palette.icon_colored_hover
} else if is_active {
palette.tab_close_active
} else {
palette.icon_color
palette.tab_close_normal
};

let font_id = FontId::new(palette.text_size, FontFamily::Proportional);
Expand Down Expand Up @@ -636,9 +639,13 @@ pub fn draw_tabbar(

if ui
.add(
egui::Label::new(egui::RichText::new("This PC").size(palette.text_size))
.selectable(false)
.sense(egui::Sense::click()),
egui::Label::new(
egui::RichText::new("This PC")
.size(palette.text_size)
.color(palette.text_header_section),
)
.selectable(false)
.sense(egui::Sense::click()),
)
.clicked()
{
Expand All @@ -661,7 +668,7 @@ pub fn draw_tabbar(
ui.label(
egui::RichText::new(">")
.size(palette.text_size)
.color(ui.visuals().widgets.noninteractive.fg_stroke.color),
.color(palette.text_header_section),
);

ui.spacing_mut().item_spacing = old_spacing;
Expand All @@ -682,7 +689,9 @@ pub fn draw_tabbar(

let resp = ui.add(
egui::Label::new(
egui::RichText::new(label_text).size(palette.text_size),
egui::RichText::new(label_text)
.size(palette.text_size)
.color(palette.text_header_section),
)
.selectable(false)
.sense(egui::Sense::click()),
Expand Down
4 changes: 2 additions & 2 deletions src/gui/windows/customizetheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn selectable_mode(
ui.selectable_label(
selected,
egui::RichText::new(label).color(if selected {
palette.tab_text_normal
palette.text_normal
} else {
ui.visuals().text_color()
}),
Expand Down Expand Up @@ -74,7 +74,7 @@ pub fn draw_theme_customizer(
ui.set_style(style);
ui.set_width(ui.available_width());

let label_color = palette.item_viewer_row_text_normal;
let label_color = palette.text_normal;
let font_id = FontId::new(palette.text_size, FontFamily::Proportional);

// HEADER
Expand Down
2 changes: 1 addition & 1 deletion src/gui/windows/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn draw_settings_window(
apply_checkbox_colors(ui, palette, false);
if ui.checkbox(
&mut settings.current_settings.folder_scanning_enabled,
RichText::new("Enable folder size scanning").color(palette.tab_text_normal)
RichText::new("Enable folder size scanning").color(palette.text_normal)
).changed() {
// Auto-save when setting changes
action = Some(SettingsAction::ApplySettings);
Expand Down
Loading