diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index ee569148e4..cd6cebd5b5 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -360,6 +360,7 @@ impl PdfCraftApp { script_messages_dropped: 0, script_shown: None, posted_notices: Vec::new(), + last_edit_refusal: None, notices: craft::ui::notices::NoticeCenter::new(), progress_requests: Vec::new(), progress_cards: Default::default(), diff --git a/crates/ui-egui/src/canvas/bars.rs b/crates/ui-egui/src/canvas/bars.rs index 0b6dd15953..942e948e15 100644 --- a/crates/ui-egui/src/canvas/bars.rs +++ b/crates/ui-egui/src/canvas/bars.rs @@ -180,7 +180,7 @@ pub(super) fn notices( None }; let msg = if scripts_off { - Some(("triangle-alert", Tone::Warn, crate::js_ui::scripts_off_notice(), true)) + Some(("triangle-alert", Tone::Info, crate::js_ui::scripts_off_notice(), true)) } else if secured { // A secured form still says what it is, and keeps Highlight fields: the security // sentence follows the form's. @@ -202,15 +202,16 @@ pub(super) fn notices( // What each action returns, by the action's index; `None` is the field highlight toggle. let mut results: Vec> = Vec::new(); let mut notice = bar(tone, icon, text).dismiss(); + // The stopped-scripts notice leads with the Console, then the field highlights. + if scripts_off { + notice = notice.action(NoticeAction::new(tl!("JavaScript Console").to_string())); + results.push(Some(Notice::Console)); + } if fields { let label = if view.session.highlight_fields { tl!("Hide field highlights") } else { tl!("Highlight fields") }; notice = notice.action(NoticeAction::new(label.to_string())); results.push(None); } - if scripts_off { - notice = notice.action(NoticeAction::new(tl!("JavaScript Console").to_string())); - results.push(Some(Notice::Console)); - } if secured { notice = notice.action(NoticeAction::new(tl!("Security settings").to_string())); results.push(Some(Notice::Security)); diff --git a/crates/ui-egui/src/dialogs/duplicate_field.rs b/crates/ui-egui/src/dialogs/duplicate_field.rs index 432480803c..8350751f8e 100644 --- a/crates/ui-egui/src/dialogs/duplicate_field.rs +++ b/crates/ui-egui/src/dialogs/duplicate_field.rs @@ -22,7 +22,7 @@ pub(crate) fn open(app: &mut PdfCraftApp, ctx: &egui::Context, name: String) { fields.set(FIELD, name.clone()); let line = crate::i18n::fmt(tl!("Duplicate \"{name}\" onto:"), &[("name", &name)]); let dialog = HostedParamDialog::new(ctx, "form.duplicate_field", fields, move |fields| { - let rows = vec![PageRangeOptions::param("pages", "", count, current, PageRangeChoices::Acrobat)]; + let rows = vec![PageRangeOptions::param("pages", "", count, current, PageRangeChoices::FromTo)]; ParamDialog::new("form.duplicate_field", tl!("Duplicate Field"), rows).title_note(line.clone()).values(Bind::bound(fields)) }); crate::dialogs::host::open(app, dialog); diff --git a/crates/ui-egui/src/editing.rs b/crates/ui-egui/src/editing.rs index ae7c9af666..dfde07281d 100644 --- a/crates/ui-egui/src/editing.rs +++ b/crates/ui-egui/src/editing.rs @@ -314,7 +314,9 @@ impl PdfCraftApp { } } let message = if matches!(edit, Edit::MoveObjects { .. }) { crate::object_ui::move_error(&e) } else { e.to_string() }; - self.notify_fmt("{label} failed: {e}", &[("label", &crate::i18n::edit_label(&label)), ("e", &message)]); + let text = crate::i18n::fmt(tl!("{label} failed: {e}"), &[("label", &crate::i18n::edit_label(&label)), ("e", &message)]); + self.last_edit_refusal = Some(text.clone()); + self.notify(text); false } } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 74a2d789b1..773e3e9405 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -473,6 +473,8 @@ pub struct PdfCraftApp { pub(crate) script_shown: Option, /// The notices posted since the last pass, which `notices::show` hands to the toast service. pub(crate) posted_notices: Vec, + /// The text of the last refused edit's notice, for a dialog that shows the refusal in place. + pub(crate) last_edit_refusal: Option, /// The notice center that posts them and shows the cards. pub(crate) notices: craft::ui::notices::NoticeCenter, /// The changes to progress cards made since the last pass, which `notices::show` applies in order. diff --git a/crates/ui-egui/src/tools/bulk_fields.rs b/crates/ui-egui/src/tools/bulk_fields.rs index d86febddb9..cdebe756f2 100644 --- a/crates/ui-egui/src/tools/bulk_fields.rs +++ b/crates/ui-egui/src/tools/bulk_fields.rs @@ -414,10 +414,12 @@ fn apply(ctx: &egui::Context, app: &mut PdfCraftApp, draft: &Draft) -> Result<() return Ok(()); } // `apply_edit` posts its own reason as a notice; the dialog's refusal is this fixed text. + app.last_edit_refusal = None; if app.apply_edit(ctx, Edit::Batch { label: "Change field properties".into(), edits }) { Ok(()) } else { - Err(tl!("The field properties could not be changed.").to_owned().into()) + // The edit's own reason (a locked field says to unlock it), as the dialog shows it. + Err(app.last_edit_refusal.take().map_or_else(|| tl!("The field properties could not be changed.").to_owned().into(), Label::from)) } } @@ -531,9 +533,21 @@ fn body(ui: &mut Ui, d: &mut Draft, recent: &RecentColours, request: &mut Option match d.tab { Tab::General => { let c = &mut d.tooltip; - row(ui, "Tooltip:", c, false, |ui, shown| { - TextField::new(tl!("Tooltip").to_owned(), Bind::bound_mixed(shown)).show(ui); + // A mixed tooltip shows the first field's text, editable, and says it is mixed. + let was_mixed = c.mixed; + let mut text = c.value.clone(); + row(ui, "Tooltip:", c, false, |ui, _| { + ui.horizontal(|ui| { + TextField::new(tl!("Tooltip").to_owned(), Bind::bound(&mut text)).show(ui); + if was_mixed { + Text::new(tl!("Mixed").to_owned()).show(ui); + } + }); }); + if text != c.value { + c.value = text; + c.mixed = false; + } yes_no(ui, "Read Only", &mut d.read_only); yes_no(ui, "Required", &mut d.required); yes_no(ui, "Locked", &mut d.locked); diff --git a/crates/ui-egui/src/tools/link_ui.rs b/crates/ui-egui/src/tools/link_ui.rs index 2e87351d37..653fe8090e 100644 --- a/crates/ui-egui/src/tools/link_ui.rs +++ b/crates/ui-egui/src/tools/link_ui.rs @@ -11,7 +11,9 @@ use craft::ui::canvas_controls::SelectionOutline; use craft::ui::choice::{Radio, RadioGroup}; use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _}; use craft::ui::dialog::{DialogId, DialogResult, DialogStack, StackDialog, dialog_id}; +use craft::ui::display::{Shade, Text}; use craft::ui::form::{Field, FieldGroup, Help}; +use craft::ui::layout_components::Row; use craft::ui::patterns::form_dialogs::FormDialog; use craft::ui::pickers::Select; use craft::ui::primitives::Draw; @@ -337,6 +339,7 @@ fn pick( /// The Link Appearance group. fn appearance(ui: &mut egui::Ui, d: &mut LinkDraft, request: &mut Option, recent: &RecentColours) { FieldGroup::new(tl!("Link Appearance").to_string()).show(ui, |ui, _| { + Text::new(tl!("Link Appearance").to_uppercase()).shade(Shade::Muted).show(ui); let visible = [(true, tl!("Visible Rectangle").to_string()), (false, tl!("Invisible Rectangle").to_string())]; if let Some(v) = pick(ui, tl!("Link Type").to_string(), d.style.visible, visible.to_vec()) { d.style.visible = v; @@ -385,6 +388,7 @@ fn appearance(ui: &mut egui::Ui, d: &mut LinkDraft, request: &mut Option 0).show(ui); - let count = if *n == 0 { tl!("None found").to_string() } else { n.to_string() }; - Text::new(count).shade(Shade::Muted).show(ui); + // The count stands beside its checkbox, on one row. + Row::new().show(ui, |ui, _| { + Checkbox::new(Bind::bound(on)).label(tl!(h.label())).enabled(*n > 0).show(ui); + let count = if *n == 0 { tl!("None found").to_string() } else { n.to_string() }; + Text::new(count).shade(Shade::Muted).show(ui); + }); } Text::new(tl!("Form fields are flattened: their values stay visible. Saving rewrites the whole file.")).shade(Shade::Muted).show(ui); true diff --git a/crates/ui-egui/src/workflows/actions_ui.rs b/crates/ui-egui/src/workflows/actions_ui.rs index c5cfc7fdb3..3f3908acb6 100644 --- a/crates/ui-egui/src/workflows/actions_ui.rs +++ b/crates/ui-egui/src/workflows/actions_ui.rs @@ -8,9 +8,9 @@ use craft::docpath::names::{CopyNumbering, unique_file_name}; use craft::host::queue::Priority; use craft::host::{Files, PickRequest, Picked, WriteIntent}; use craft::ui::buttons::Button; -use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _}; +use craft::ui::contract::{Bind, Entry, Props as _, RowAlign, Show as _, ShowContainer as _}; use craft::ui::dialog::{DialogId, DialogResult, DialogStack, StackDialog, dialog_id}; -use craft::ui::display::Text; +use craft::ui::display::{Shade, Text}; use craft::ui::form::{Field, FieldGroup}; use craft::ui::layout_components::Row; use craft::ui::patterns::form_dialogs::{FormDialog, ListManager, ListManagerAction, ListManagerChoice, ListManagerEntry, ListManagerWords}; @@ -132,7 +132,9 @@ impl StackDialog for ActionEditorDialog { } let mut remove = None; for (i, s) in d.steps.iter_mut().enumerate() { - Row::new().show(ui, |ui, _| { + let plain = s.arg_mut().is_none(); + let spread = if plain { RowAlign::SpaceBetween } else { RowAlign::Start }; + Row::new().fill_width().align(spread).show(ui, |ui, _| { let label = format!("{}. {}", i + 1, tl!(s.label())); Text::new(label.clone()).show(ui); if let Some(arg) = s.arg_mut() { @@ -160,6 +162,9 @@ impl StackDialog for ActionEditorDialog { } }); }); + if taken { + Text::new(tl!("An action with this name already exists.")).shade(Shade::Muted).show(ui); + } true }); match (shown.accepted, shown.closed) { diff --git a/crates/ui-egui/tests/it/bulk_fields.rs b/crates/ui-egui/tests/it/bulk_fields.rs index 69e834914a..c692087576 100644 --- a/crates/ui-egui/tests/it/bulk_fields.rs +++ b/crates/ui-egui/tests/it/bulk_fields.rs @@ -216,7 +216,8 @@ fn locked_field_refuses_the_entire_batch_and_keeps_the_draft_for_correction() { click_gate(&mut h, "Locked"); h.run_steps(4); assert_eq!(shared(&h)["locked"]["value"], false); - assert_eq!(shared(&h)["tooltip"]["value"], "Shared help", "what was typed is kept"); + // The field shows the first field's own text (the tooltip is mixed), so typing adds to it. + assert!(shared(&h)["tooltip"]["value"].as_str().is_some_and(|v| v.ends_with("Shared help")), "what was typed is kept"); h.get_by_label("OK").click(); h.run_steps(4); assert!(!shared_open(&h)); @@ -225,7 +226,7 @@ fn locked_field_refuses_the_entire_batch_and_keeps_the_draft_for_correction() { .form .iter() .filter(|f| ["alpha", "beta"].contains(&f.name.as_str())) - .all(|f| !f.locked() && f.tooltip.as_deref() == Some("Shared help")) + .all(|f| !f.locked() && f.tooltip.as_deref().is_some_and(|t| t.ends_with("Shared help"))) ); h.execute("edit.undo"); h.run_steps(4);