From edee301ebf8f719a5574949e17919c1bb8cddd16 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 30 Oct 2026 07:55:28 -0600 Subject: [PATCH] M5.7: the Fill & Sign button follows the active tool and names it Tools restored without a command (leaving full screen, the temporary tool, the control channel) left the remembered Fill & Sign tool stale, so the button could show Checkmark while a click placed a signature. The bar now takes the remembered tool from the active one, which replaces the dialog's and control channel's own updates. While a Fill & Sign tool is active the button opens the flyout, so its label names the tool instead of describing placing or adding a signature. --- crates/ui-egui/src/app/control.rs | 9 +++------ crates/ui-egui/src/dialogs.rs | 1 - crates/ui-egui/src/hotbar.rs | 5 ++++- crates/ui-egui/tests/it/fill_sign.rs | 14 +++++++++++--- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/app/control.rs b/crates/ui-egui/src/app/control.rs index fee5378b6e..0309042bf1 100644 --- a/crates/ui-egui/src/app/control.rs +++ b/crates/ui-egui/src/app/control.rs @@ -333,12 +333,9 @@ impl PdfCraftApp { field if field.starts_with("field-") => QuickTool::Field( prepare::FieldTool::from_command(&format!("form.add.{}", &field[6..])).ok_or_else(|| format!("unknown tool {field}"))?, ), - fill if fill.starts_with("fill-") => { - let f = - fill_sign::FillTool::from_command(&format!("sign.fill.{}", &fill[5..])).ok_or_else(|| format!("unknown tool {fill}"))?; - self.fill_tool = f; - QuickTool::Fill(f) - } + fill if fill.starts_with("fill-") => QuickTool::Fill( + fill_sign::FillTool::from_command(&format!("sign.fill.{}", &fill[5..])).ok_or_else(|| format!("unknown tool {fill}"))?, + ), other => { let t = comments::CommentTool::from_command(&format!("comment.{other}")).ok_or_else(|| format!("unknown tool {other}"))?; self.comment_prefs.group_tool[t.group()] = t; diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 8105a22342..048d519222 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -1349,7 +1349,6 @@ fn dialog_signature(ui: &mut egui::Ui, app: &mut PdfCraftApp, req: &mut Pending) app.signature = d.saved(); crate::fill_sign::FillTool::Signature }; - app.fill_tool = tool; app.quick_tool = crate::QuickTool::Fill(tool); app.toast = None; } diff --git a/crates/ui-egui/src/hotbar.rs b/crates/ui-egui/src/hotbar.rs index bbd98be2ef..88c45bbd1e 100644 --- a/crates/ui-egui/src/hotbar.rs +++ b/crates/ui-egui/src/hotbar.rs @@ -239,9 +239,12 @@ fn core_tool_buttons(ui: &mut egui::Ui, app: &mut PdfCraftApp, cell: f32, popup_ QuickTool::Fill(f) => Some(f), _ => None, }; + if let Some(f) = current_fill { + app.fill_tool = f; + } let shown = app.fill_tool; let tip = match shown { - crate::fill_sign::FillTool::Signature | crate::fill_sign::FillTool::Initials => { + crate::fill_sign::FillTool::Signature | crate::fill_sign::FillTool::Initials if current_fill.is_none() => { let initials = shown == crate::fill_sign::FillTool::Initials; let saved = if initials { app.initials.is_some() } else { app.signature.is_some() }; crate::i18n::fmt( diff --git a/crates/ui-egui/tests/it/fill_sign.rs b/crates/ui-egui/tests/it/fill_sign.rs index 503080e71c..bd8bd30939 100644 --- a/crates/ui-egui/tests/it/fill_sign.rs +++ b/crates/ui-egui/tests/it/fill_sign.rs @@ -425,7 +425,7 @@ fn changing_saved_signatures_and_initials_preserves_placed_marks() { // The quick toolbar exposes replacement without changing the normal placement action. h.get_by_label("Fill & Sign: Place saved signature").click(); h.run_steps(2); - h.get_by_label("Fill & Sign: Place saved signature").click(); + h.get_by_label("Fill & Sign: Sign").click(); h.run_steps(2); h.get_by_label("Change signature").click(); h.run_steps(2); @@ -447,7 +447,7 @@ fn changing_saved_signatures_and_initials_preserves_placed_marks() { h.get_by_label("Fill & Sign: Place saved signature").click(); h.run_steps(2); - h.get_by_label("Fill & Sign: Place saved signature").click(); + h.get_by_label("Fill & Sign: Sign").click(); h.run_steps(2); h.get_by_label("Change initials").click(); h.run_steps(2); @@ -1829,7 +1829,7 @@ fn the_quick_bar_fill_button_shows_the_tool_it_picks() { h.run_steps(2); assert_eq!(h.state().quick_tool, QuickTool::Fill(FillTool::Signature)); assert_eq!(h.state().dialog, None); - h.get_by_label("Fill & Sign: Place saved signature").click(); + h.get_by_label("Fill & Sign: Sign").click(); h.run_steps(2); assert_eq!(h.get_by_label("Use signature").accesskit_node().toggled(), Some(egui::accesskit::Toggled::True), "the active tool's card is marked"); h.key_press(egui::Key::Escape); @@ -1841,4 +1841,12 @@ fn the_quick_bar_fill_button_shows_the_tool_it_picks() { h.get_by_label("Fill & Sign: Checkmark").click(); h.run_steps(2); assert_eq!(h.state().quick_tool, QuickTool::Fill(FillTool::Check), "the button keeps the last Fill & Sign tool"); + + h.state_mut().quick_tool = QuickTool::Fill(FillTool::Initials); + h.run_steps(2); + h.state_mut().quick_tool = QuickTool::Select; + h.run_steps(2); + h.get_by_label("Fill & Sign: Add initials").click(); + h.run_steps(2); + assert_eq!(h.state().quick_tool, QuickTool::Fill(FillTool::Initials), "a tool restored without a command still updates the button"); }