forked from 1b-agent/opencadstudio-upstream
Options: color book folder shown like the other locations
Options > Files lists the color book folder as a read-only row with Open folder, like Plot styles or Fonts. The Add folder / Remove buttons, their messages and the explanatory line (in all 22 locales) are gone; the folder list stays in the settings for a later location option. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013rGmDUNr1hUf4zo1X3dak8
This commit is contained in:
26 files changed
+7
-100
No files matched your search
@@ -4341,10 +4341,6 @@ pub enum Message {
|
||||
/// An `.acb` file was read (and, on desktop, copied into the first
|
||||
/// colour book folder).
|
||||
ColorBookLoaded(Result<crate::ui::color_select::book::ColorBook, String>),
|
||||
/// Options › Files: pick a folder to search for colour books.
|
||||
ColorBookDirBrowse,
|
||||
ColorBookDirAdd(String),
|
||||
ColorBookDirRemove(usize),
|
||||
/// Set a block/linetype Handle field on the selected dim style from a
|
||||
/// dropdown of available block-records / linetypes (by name).
|
||||
DsSetHandle {
|
||||
|
||||
@@ -11993,35 +11993,6 @@ impl OpenCADStudio {
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Message::ColorBookDirBrowse => Task::perform(
|
||||
async {
|
||||
crate::sys::file_dialog()
|
||||
.pick_folder()
|
||||
.await
|
||||
.map(|handle| crate::sys::handle_path(&handle).display().to_string())
|
||||
},
|
||||
|dir| dir.map_or(Message::Noop, Message::ColorBookDirAdd),
|
||||
),
|
||||
// Browsers expose no folder picker.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Message::ColorBookDirBrowse => Task::none(),
|
||||
Message::ColorBookDirAdd(dir) => {
|
||||
if !self.color_book_dirs.contains(&dir) {
|
||||
self.color_book_dirs.push(dir);
|
||||
self.color_books_read = false;
|
||||
self.persist_settings_if_changed();
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::ColorBookDirRemove(i) => {
|
||||
if i < self.color_book_dirs.len() {
|
||||
self.color_book_dirs.remove(i);
|
||||
self.color_books_read = false;
|
||||
self.persist_settings_if_changed();
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::DsSetHandle { field, value } => self.on_ds_set_handle(field, value),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4945,7 +4945,6 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
|
||||
"This color book is encrypted and cannot be read" => Some(("common", "color-book-encrypted")),
|
||||
"The color book has no colors" => Some(("common", "color-book-empty")),
|
||||
"Color book locations" => Some(("common", "color-book-locations")),
|
||||
"Folders searched for .acb color books. A book loaded in Select Color is copied into the first folder." => Some(("common", "color-book-locations-hint")),
|
||||
"CAD Color Index (ACI) 10–249" => Some(("common", "cad-color-index-aci-10-249")),
|
||||
"Grayscale 250–255" => Some(("common", "grayscale-250-255")),
|
||||
"Isometric drafting" => Some(("common", "isometric-drafting")),
|
||||
|
||||
@@ -1773,49 +1773,6 @@ pub fn view_window<'a>(
|
||||
.align_y(iced::Center)
|
||||
};
|
||||
|
||||
// Searched for `.acb` colour books; editable, unlike the folders above.
|
||||
// Browsers have no folders, so the web build leaves it out.
|
||||
let color_book_locations = |dirs: &'a [String]| -> Element<'a, Message> {
|
||||
if cfg!(target_arch = "wasm32") {
|
||||
return Space::new().into();
|
||||
}
|
||||
let list = dirs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.fold(column![].spacing(6), |list, (i, dir)| {
|
||||
list.push(
|
||||
row![
|
||||
text(dir.as_str()).size(11).width(Fill),
|
||||
button(text(crate::t!("Open folder")).size(11))
|
||||
.padding([4, 10])
|
||||
.style(button::secondary)
|
||||
.on_press(Message::OpenFolder(dir.clone())),
|
||||
button(text(crate::t!("Remove")).size(11))
|
||||
.padding([4, 10])
|
||||
.style(button::secondary)
|
||||
.on_press(Message::ColorBookDirRemove(i)),
|
||||
]
|
||||
.spacing(10)
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
});
|
||||
column![
|
||||
text(crate::t!("Color book locations")).size(12),
|
||||
text(crate::t!(
|
||||
"Folders searched for .acb color books. A book loaded in Select Color is copied into the first folder."
|
||||
))
|
||||
.size(11),
|
||||
list,
|
||||
button(text(crate::t!("Add folder…")).size(11))
|
||||
.padding([4, 10])
|
||||
.style(button::secondary)
|
||||
.on_press(Message::ColorBookDirBrowse),
|
||||
Space::new().height(16),
|
||||
]
|
||||
.spacing(6)
|
||||
.into()
|
||||
};
|
||||
|
||||
let files = column![
|
||||
text(crate::t!("Files")).size(15),
|
||||
Space::new().height(6),
|
||||
@@ -1834,8 +1791,14 @@ pub fn view_window<'a>(
|
||||
folder_row(crate::t!("Autosave files"), folders.autosave.clone()),
|
||||
Space::new().height(12),
|
||||
folder_row(crate::t!("Fonts"), folders.fonts.clone()),
|
||||
// Where `.acb` colour books are found (none on the web).
|
||||
color_book_dirs.iter().fold(column![], |rows, dir| rows
|
||||
.push(Space::new().height(12))
|
||||
.push(folder_row(
|
||||
crate::t!("Color book locations"),
|
||||
Some(dir.clone())
|
||||
))),
|
||||
Space::new().height(16),
|
||||
color_book_locations(color_book_dirs),
|
||||
text(crate::t!("Default template for new drawings")).size(12),
|
||||
Space::new().height(4),
|
||||
row![
|
||||
|
||||
Reference in new issue
Block a user