forked from 1b-agent/opencadstudio-upstream
options: fonts and plot styles can live in a chosen folder
Options > Files lets the fonts and plot style folders move elsewhere, such as a share a whole team uses (Change... / Default). Fonts are then looked up and downloaded there, and plot style tables listed and saved there; the choice is kept in the profile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e9a2b9d196
commit
686fb71780
8 files changed
+147
-15
No files matched your search
@@ -2694,6 +2694,11 @@ pub enum Message {
|
||||
SelectionCyclingChanged(bool),
|
||||
/// Reveal one of the application's own folders in the system file manager.
|
||||
OpenFolder(String),
|
||||
/// Choose another folder for fonts or plot styles (`None` result:
|
||||
/// cancelled).
|
||||
ChooseFolder(crate::ui::window::options::MovableFolder),
|
||||
/// Use this folder, or the default one for `None`.
|
||||
FolderChosen(crate::ui::window::options::MovableFolder, Option<std::path::PathBuf>),
|
||||
/// Change isolines per surface in the current drawing (ISOLINES).
|
||||
IsolinesChanged(i16),
|
||||
/// The isolines slider was released; rebuild the meshes if it moved.
|
||||
|
||||
@@ -443,6 +443,9 @@ pub struct UserSettings {
|
||||
pub file_dia: bool,
|
||||
/// TRIMEXTENDMODE: TRIM and EXTEND start in Quick mode (else Standard).
|
||||
pub trim_extend_quick: bool,
|
||||
/// Fonts and plot styles kept in a chosen folder (`None`: the default).
|
||||
pub fonts_folder: Option<String>,
|
||||
pub plot_styles_folder: Option<String>,
|
||||
/// The file type ATTACH's picker was last left on (1-based).
|
||||
pub attach_filter: u32,
|
||||
/// SURFACEASSOCIATIVITY: new surfaces stay associative to their sources.
|
||||
@@ -918,6 +921,8 @@ impl Default for UserSettings {
|
||||
xref_fade: 50,
|
||||
file_dia: true,
|
||||
trim_extend_quick: true,
|
||||
fonts_folder: None,
|
||||
plot_styles_folder: None,
|
||||
attach_filter: 7,
|
||||
surface_associativity: true,
|
||||
ucs_ortho: true,
|
||||
|
||||
@@ -811,6 +811,15 @@ impl OpenCADStudio {
|
||||
xref_fade: crate::scene::cache::block_cache::xref_fade_ctl(),
|
||||
file_dia: crate::sys::file_dia(),
|
||||
trim_extend_quick: crate::modules::draw::modify::trim::quick_mode(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fonts_folder: crate::io::font_repo::fonts_folder().map(|p| p.display().to_string()),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
plot_styles_folder: crate::io::plot_style::plot_styles_folder()
|
||||
.map(|p| p.display().to_string()),
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fonts_folder: None,
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
plot_styles_folder: None,
|
||||
attach_filter: crate::sys::attach_filter(),
|
||||
surface_associativity: crate::scene::model::sweep_model::surface_associativity(),
|
||||
ucs_ortho: crate::modules::view::view_cmd::ucs_ortho(),
|
||||
@@ -948,6 +957,13 @@ impl OpenCADStudio {
|
||||
self.ribbon.xref_fade = crate::scene::cache::block_cache::xref_fade_ctl();
|
||||
crate::sys::set_file_dia(s.file_dia);
|
||||
crate::modules::draw::modify::trim::set_quick_mode(s.trim_extend_quick);
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
crate::io::font_repo::set_fonts_folder(s.fonts_folder.as_ref().map(Into::into));
|
||||
crate::io::plot_style::set_plot_styles_folder(
|
||||
s.plot_styles_folder.as_ref().map(Into::into),
|
||||
);
|
||||
}
|
||||
crate::sys::set_attach_filter(s.attach_filter);
|
||||
crate::scene::model::sweep_model::set_surface_associativity(s.surface_associativity);
|
||||
crate::modules::view::view_cmd::set_ucs_ortho(s.ucs_ortho);
|
||||
|
||||
@@ -9369,6 +9369,34 @@ impl OpenCADStudio {
|
||||
crate::sys::open_url(&path, None)
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Message::ChooseFolder(_) | Message::FolderChosen(..) => Task::none(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Message::ChooseFolder(folder) => Task::perform(
|
||||
async {
|
||||
rfd::AsyncFileDialog::new()
|
||||
.pick_folder()
|
||||
.await
|
||||
.map(|handle| crate::sys::handle_path(&handle))
|
||||
},
|
||||
move |picked| match picked {
|
||||
Some(path) => Message::FolderChosen(folder, Some(path)),
|
||||
None => Message::Noop,
|
||||
},
|
||||
),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Message::FolderChosen(folder, path) => {
|
||||
use crate::ui::window::options::MovableFolder;
|
||||
match folder {
|
||||
MovableFolder::Fonts => crate::io::font_repo::set_fonts_folder(path),
|
||||
MovableFolder::PlotStyles => {
|
||||
crate::io::plot_style::set_plot_styles_folder(path)
|
||||
}
|
||||
}
|
||||
self.save_config();
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::PickDragRectToggled(rectangle) => {
|
||||
self.pick_drag_rect = rectangle;
|
||||
self.persist_settings_if_changed();
|
||||
|
||||
@@ -375,6 +375,9 @@ impl OpenCADStudio {
|
||||
.map(|p| p.display().to_string()),
|
||||
color_books: crate::ui::color_select::book::folder()
|
||||
.map(|p| p.display().to_string()),
|
||||
fonts_moved: crate::io::font_repo::fonts_folder().is_some(),
|
||||
plot_styles_moved: crate::io::plot_style::plot_styles_folder()
|
||||
.is_some(),
|
||||
}
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
||||
Reference in new issue
Block a user