Integration: #2809 opening a document into Read mode puts the tool down

This commit is contained in:
aiongg
2026-10-16 14:03:56 +00:00
parent eb7e0d9d3e
commit 2d5809b7a6
2 changed files with 20 additions and 0 deletions
+5
View File
@@ -2152,6 +2152,11 @@ impl PdfCraftApp {
} else if matches!(self.quick_tool, QuickTool::EditText | QuickTool::AddText) {
self.put_down_edit_text();
}
// Read mode hides the quick toolbar, so no other tool may stay active there. Opening a
// document with Read as the default mode comes here without `switch_mode`.
if mode == Mode::Read {
self.quick_tool = QuickTool::Select;
}
}
/// Back to the Select tool from an editing tool. A paragraph still open in the editor is
+15
View File
@@ -264,6 +264,21 @@ fn read_mode_hides_the_quick_toolbar() {
h.get_by_label("Select (V)");
}
/// Opening a document with Read as the default mode puts down the tool in use, as entering Read
/// mode from the mode bar does: the hidden toolbar would leave no way to see or change it.
#[test]
fn opening_into_read_mode_puts_the_tool_down() {
use pdfcraft_ui_egui::{Mode, QuickTool};
let mut h = harness(|app| app.open_bytes("fixture.pdf", None, FIXTURE.to_vec()).expect("fixture opens"));
assert_eq!(h.state().mode, Mode::AllTools);
h.state_mut().set_option("quick", "hand").unwrap();
h.state_mut().set_option("default-mode", "read").unwrap();
h.state_mut().open_bytes("again.pdf", None, FIXTURE.to_vec()).unwrap();
h.run_steps(3);
assert_eq!(h.state().mode, Mode::Read, "the new document opens in the default mode");
assert_eq!(h.state().quick_tool, QuickTool::Select, "no tool stays active behind the hidden toolbar");
}
/// A pane closed in Read mode stays closed on the way out: leaving Read mode doesn't bring back the
/// pane saved on the way in, and closing Comments keeps its close preference.
#[test]