mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-13 22:32:19 +00:00
M5.7: the Fill & Sign button remembers tools where they are selected
The quick bar copied the active tool into fill_tool on every draw, so a tool restored on leaving full screen replaced the last selection, and a tool selected while the bar was hidden was forgotten. The signature dialog and the control channel now record the tool when they select it, and the bar only reads: the active tool if there is one, otherwise the remembered one.
This commit is contained in:
1 parent
2e699f489a
commit
6028bdab7c
4 files changed
+51
-10
No files matched your search
@@ -333,9 +333,12 @@ 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-") => QuickTool::Fill(
|
||||
fill_sign::FillTool::from_command(&format!("sign.fill.{}", &fill[5..])).ok_or_else(|| format!("unknown tool {fill}"))?,
|
||||
),
|
||||
fill if fill.starts_with("fill-") => {
|
||||
let tool =
|
||||
fill_sign::FillTool::from_command(&format!("sign.fill.{}", &fill[5..])).ok_or_else(|| format!("unknown tool {fill}"))?;
|
||||
self.fill_tool = tool;
|
||||
QuickTool::Fill(tool)
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -1349,6 +1349,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -239,10 +239,7 @@ 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 shown = current_fill.unwrap_or(app.fill_tool);
|
||||
let tip = match shown {
|
||||
crate::fill_sign::FillTool::Signature | crate::fill_sign::FillTool::Initials if current_fill.is_none() => {
|
||||
let initials = shown == crate::fill_sign::FillTool::Initials;
|
||||
|
||||
@@ -1841,14 +1841,54 @@ 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);
|
||||
#[test]
|
||||
fn a_restored_fill_tool_shows_without_replacing_the_last_selection() {
|
||||
let mut h = harness();
|
||||
h.state_mut().execute("sign.fill.date");
|
||||
h.run_steps(2);
|
||||
h.state_mut().apply_full_screen(true);
|
||||
h.run_steps(2);
|
||||
h.state_mut().execute("sign.fill.check");
|
||||
h.run_steps(2);
|
||||
h.state_mut().apply_full_screen(false);
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().quick_tool, QuickTool::Fill(FillTool::Date));
|
||||
h.get_by_label("Fill & Sign: Date");
|
||||
|
||||
h.state_mut().quick_tool = QuickTool::Select;
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Fill & Sign: Add initials").click();
|
||||
h.get_by_label("Fill & Sign: Checkmark").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");
|
||||
assert_eq!(h.state().quick_tool, QuickTool::Fill(FillTool::Check));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fill_tool_selected_while_the_quick_bar_is_hidden_is_remembered() {
|
||||
let mut h = harness();
|
||||
let mode = h.state().mode;
|
||||
h.state_mut().set_option("mode", "read").unwrap();
|
||||
h.run_steps(2);
|
||||
h.state_mut().set_option("quick", "fill-date").unwrap();
|
||||
h.run_steps(2);
|
||||
h.state_mut().set_option("quick", "select").unwrap();
|
||||
h.state_mut().mode = mode;
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Fill & Sign: Date");
|
||||
|
||||
h.state_mut().initials = Some(SavedSig::Typed("AL".into()));
|
||||
h.state_mut().set_option("mode", "read").unwrap();
|
||||
h.run_steps(2);
|
||||
h.state_mut().execute("sign.fill.initials.change");
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Apply").click();
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().quick_tool, QuickTool::Fill(FillTool::Initials));
|
||||
h.state_mut().quick_tool = QuickTool::Select;
|
||||
h.state_mut().mode = mode;
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Fill & Sign: Place saved initials");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user