Remember annotation mode

This commit is contained in:
rope 2026-09-20 13:23:07 +01:00
parent 3eaaae6847
commit ea07c37fe0
2 changed files with 18 additions and 1 deletions

View file

@ -9,5 +9,9 @@
<default>true</default> <default>true</default>
<summary>Copy the image to the clipboard after annotation changes</summary> <summary>Copy the image to the clipboard after annotation changes</summary>
</key> </key>
<key name="annotation-mode" type="b">
<default>true</default>
<summary>Open images in annotation mode</summary>
</key>
</schema> </schema>
</schemalist> </schemalist>

View file

@ -489,12 +489,17 @@ mod imp {
} }
}); });
// Connect draw mode button (headerbar toggle) // Remember annotation mode and apply it to each newly opened image.
let draw_mode_settings = LpApplication::default().settings();
imp.draw_mode_button.connect_toggled(glib::clone!( imp.draw_mode_button.connect_toggled(glib::clone!(
#[weak] #[weak]
obj, obj,
move |btn| { move |btn| {
let active = btn.is_active(); let active = btn.is_active();
if let Err(err) = draw_mode_settings.set_boolean("annotation-mode", active)
{
tracing::warn!("Failed to save annotation mode setting: {err}");
}
let imp = obj.imp(); let imp = obj.imp();
imp.draw_toolbar_revealer.set_reveal_child(active); imp.draw_toolbar_revealer.set_reveal_child(active);
if let Some(img) = imp.image_view.current_image() { if let Some(img) = imp.image_view.current_image() {
@ -509,6 +514,11 @@ mod imp {
} }
} }
)); ));
imp.draw_mode_button.set_active(
LpApplication::default()
.settings()
.boolean("annotation-mode"),
);
// Tool buttons // Tool buttons
imp.draw_freeform_btn.connect_toggled(glib::clone!( imp.draw_freeform_btn.connect_toggled(glib::clone!(
@ -1004,6 +1014,9 @@ impl LpImageWindow {
// Properties view // Properties view
let current_image: Option<LpImage> = current_page.as_ref().map(|x| x.image()); let current_image: Option<LpImage> = current_page.as_ref().map(|x| x.image());
imp.properties_view.set_image(current_image.as_ref()); imp.properties_view.set_image(current_image.as_ref());
if let Some(image) = current_image.as_ref() {
image.set_drawing_mode(imp.draw_mode_button.is_active());
}
let has_image = current_page.is_some(); let has_image = current_page.is_some();