feat: make focus mode toggleable by a pen button - #1820
Conversation
Adds ShortcutAction::ToggleFocusMode and the WidgetFlags::toggle_focus_mode flag. The penholder sets the flag when the action is dispatched, and RnAppWindow toggles its focus-mode property accordingly.
Adds a "focus mode" marker entry to the pen shortcut picker list model and updates both the list and icon factories to render it (label + icon), while leaving the existing pen style entries unchanged
Updates RnPenShortcutRow so selecting the "Focus mode" entry maps to ShortcutAction::ToggleFocusMode and hides the mode dropdown, while a pen style entry maps back to ChangePenStyle preserving the previous mode. Focus-mode detection is now position-independent: it queries the StringList by its FOCUS_MODE_ENTRY marker instead of assuming it is the last entry
ChangePenStyleListModel/ChangePenStyleListFactory/ ChangePenStyleIconFactory to PenShortcutActionListModel/ PenShortcutActionListFactory/PenShortcutActionIconFactory, and the model field changepenstyle_model to shortcut_actions_model. The model is no longer limited to pen styles since it also holds the "Focus mode" shortcut action.
muditchaudhari
left a comment
There was a problem hiding this comment.
Nice feature — reusing the existing pen shortcut infrastructure rather than adding a separate binding mechanism seems like the right call, and the engine side follows the existing WidgetFlags pattern closely (default, BitOrAssign, handled in handle_widget_flags). Adding #[serde(rename = "toggle_focus_mode")] so persisted shortcut configs stay stable is a nice touch.
A few things I noticed while reading through it, left inline. Not a maintainer, just a fellow contributor — take or leave as you see fit.
I also checked the two things that looked most likely to cause trouble, and both are fine: focus-mode-symbolic is present in crates/rnote-ui/data/icons/scalable/actions/ and registered in the gresource, and StringList::find() is gated behind gtk4-rs's v4_18 feature, which matches the project's gtk4 >= 4.18 requirement — so no minimum version bump is implied.
Disclosure: I used an AI assistant while reviewing this.
icon name - Spell out ShortcutAction::ToggleFocusMode in both non-exhaustive matches in penshortcutrow.rs instead of the `_` arm. - Add FOCUS_MODE_ICON_NAME constant and use it in both the list and icon factories in penshortcutmodels.rs.
Closes #1785
Adds a new
ShortcutActionso any pen shortcut key (stylus buttons, drawing pad buttons, touch two-finger long press,keyboard Ctrl+Space, …) can be bound to toggle the app's focus mode from the existing pen shortcut settings, without changing any default shortcuts.Changes
Engine (
rnote-engine)ShortcutActionto toggle Focus mode.UI (
rnote-ui)Testing
cargo fmt --checkcargo clippy --workspace --all-targets -- -D warnings(no warnings)cargo test --workspacemeson compile ui-cargo-clippy -C _mesonbuildmeson compile cli-cargo-clippy -C _mesonbuildmeson test -C _mesonbuild(3/3 OK)toggles and the shortcut remains configured after reopening the settings.
focus.mode.mp4
Disclosure
This implementation was created with the assistance of an LLM.