Skip to content

Commit e3454c4

Browse files
committed
feat: add button to open settings directory from U
- Added a helper method to retrieve the application config directory. - Implemented a folder button (📁) in the Settings panel header. - Added cross-platform support for opening the directory in the default file manager (Explorer, xdg-open, or open).
1 parent 7b60b3a commit e3454c4

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/settings.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ impl Settings {
487487
}
488488
}
489489
}
490+
491+
pub fn get_config_dir() -> Option<std::path::PathBuf> {
492+
dirs::config_dir().map(|d| d.join("sen"))
493+
}
490494
}
491495

492496

src/ui_panels.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,27 @@ impl EditorApp {
77
/// Render settings panel
88
pub(crate) fn render_settings_panel(&mut self, ui: &mut egui::Ui) {
99
ui.vertical(|ui| {
10-
ui.heading("⚙ Settings");
10+
ui.horizontal(|ui| {
11+
ui.heading("⚙ Settings");
12+
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
13+
if ui.button("📁").on_hover_text("Open settings folder").clicked() {
14+
if let Some(path) = crate::settings::Settings::get_config_dir() {
15+
#[cfg(target_os = "windows")]
16+
{
17+
let _ = std::process::Command::new("explorer").arg(path).spawn();
18+
}
19+
#[cfg(target_os = "linux")]
20+
{
21+
let _ = std::process::Command::new("xdg-open").arg(path).spawn();
22+
}
23+
#[cfg(target_os = "macos")]
24+
{
25+
let _ = std::process::Command::new("open").arg(path).spawn();
26+
}
27+
}
28+
}
29+
});
30+
});
1131

1232
egui::ScrollArea::vertical()
1333
.auto_shrink([false, false])

0 commit comments

Comments
 (0)