Merge pull request #1812 from ramox81/codex/import-dgnimport

IMPORT window and DGNIMPORT / -DGNIMPORT

# Conflicts:
#	locales/ar-SA/opencadstudio.ftl
#	locales/bg-BG/opencadstudio.ftl
#	locales/cs-CZ/opencadstudio.ftl
#	locales/de-DE/opencadstudio.ftl
#	locales/el-GR/opencadstudio.ftl
#	locales/en-US/opencadstudio.ftl
#	locales/es-ES/opencadstudio.ftl
#	locales/fi-FI/opencadstudio.ftl
#	locales/fr-FR/opencadstudio.ftl
#	locales/hi-IN/opencadstudio.ftl
#	locales/hu-HU/opencadstudio.ftl
#	locales/it-IT/opencadstudio.ftl
#	locales/ja-JP/opencadstudio.ftl
#	locales/ko-KR/opencadstudio.ftl
#	locales/lo-LA/opencadstudio.ftl
#	locales/nl-NL/opencadstudio.ftl
#	locales/pl-PL/opencadstudio.ftl
#	locales/pt-BR/opencadstudio.ftl
#	locales/ru-RU/opencadstudio.ftl
#	locales/tr-TR/opencadstudio.ftl
#	locales/zh-CN/opencadstudio.ftl
#	locales/zh-TW/opencadstudio.ftl
This commit is contained in:
Hakan Seven committed 2026-10-15 16:47:21 +03:00
commit 2b4c4bfdc6
39 files changed
+3210 -13

No files matched your search

+86
View File
@@ -108,6 +108,8 @@ pub(super) const NAMES: &[&str] = &[
"txt2mtxt_settings",
"view_background",
"image_adjust",
"import_file_dialog",
"dgn_import_dialog",
"refedit_dialog",
"pdf_layer_toggle",
"pc_manager_toggle",
@@ -2161,6 +2163,90 @@ impl OpenCADStudio {
_ => return Err(bad()),
}
}
// The Import File window, one field per call: "path=<file>",
// "format=<index or name>", "search=<text>", "filter=all|supported",
// "recent=<n>", "ok" or "cancel".
"import_file_dialog" => {
use crate::ui::window::import_dialogs::{ImportDialogMsg as I, FORMATS};
if self.active_modal != Some(crate::app::ModalKind::ImportFile) {
return Err(failure("no_dialog", "The Import File window is not open"));
}
let spec = string(req, "value")?;
let (key, value) = spec.split_once('=').unwrap_or((spec, ""));
let bad = || failure("invalid_value", spec);
if key == "cancel" {
return Ok(Task::done(Message::CloseModal));
}
Message::ImportDialog(match key {
"ok" => I::ImportOk,
"path" => I::Path(value.to_string()),
"search" => I::Search(value.to_string()),
"filter" => I::OnlySupported(match value {
"all" => false,
"supported" => true,
_ => return Err(bad()),
}),
"recent" => I::Recent(value.trim().parse().map_err(|_| bad())?),
"format" => I::Format(match value.trim().parse::<usize>() {
Ok(k) if k < FORMATS.len() => k,
_ => FORMATS
.iter()
.position(|f| f.name.eq_ignore_ascii_case(value.trim()))
.ok_or_else(bad)?,
}),
_ => return Err(bad()),
})
}
// The DGN Import window, one field per call: "path=<file>" (as
// Change… picks it), "model=<n>", "target=new|current",
// "conflict=prefix|ignore", "units=master|sub", "explode=on|off",
// "mapping=layer|linetype|lineweight|color", "ok" or "cancel".
"dgn_import_dialog" => {
use crate::ui::window::import_dialogs::ImportDialogMsg as I;
if self.active_modal != Some(crate::app::ModalKind::DgnImport) {
return Err(failure("no_dialog", "The DGN Import window is not open"));
}
let spec = string(req, "value")?;
let (key, value) = spec.split_once('=').unwrap_or((spec, ""));
let bad = || failure("invalid_value", spec);
let on = |v: &str| match v {
"on" | "1" | "true" => Ok(true),
"off" | "0" | "false" => Ok(false),
_ => Err(bad()),
};
if key == "cancel" {
return Ok(Task::done(Message::CloseModal));
}
Message::ImportDialog(match key {
"ok" => I::DgnOk,
"path" => I::DgnPicked(Some(value.to_string())),
"model" => I::DgnModel(value.trim().parse().map_err(|_| bad())?),
"target" => I::DgnCurrent(match value {
"new" => false,
"current" => true,
_ => return Err(bad()),
}),
"conflict" => I::DgnPrefix(match value {
"prefix" => true,
"ignore" => false,
_ => return Err(bad()),
}),
"units" => I::DgnSub(match value {
"master" => false,
"sub" => true,
_ => return Err(bad()),
}),
"explode" => I::DgnExplode(on(value)?),
"mapping" => I::DgnMappingTab(match value {
"layer" => 0,
"linetype" => 1,
"lineweight" => 2,
"color" => 3,
_ => return Err(bad()),
}),
_ => return Err(bad()),
})
}
// The Image Adjust dialog, one field per call: "brightness=70",
// "contrast=40", "fade=20" (the bar), "type=fade,abc" (typed into
// the box), "step=brightness,+1|-1", "reset", "apply" or "cancel".