Feature/printer params#23
Conversation
Adds printSpeed, darkness, mediaType, printOrientation, defaultFont as optional fields. All fields are .optional() so existing persisted designs load unchanged.
Adds emit logic for printSpeed (^PR), darkness (^MD), mediaType (^MT), printOrientation (^PO) and defaultFont (^CF). Order follows ZPL II header convention; emits only when value is set, with darkness=0 treated as a valid value rather than absence.
Parser now recognises ^PR (print speed), ^MD (darkness), ^MT (media type), ^PO (print orientation) and extends ^CF to populate labelConfig.defaultFont. Removes ^PR/^MT from the noop list. Tests cover each command including the darkness=0 boundary and a full generate-parse round-trip.
Adds 15 new keys under the label block for the printer-settings UI in all 32 locales: printerSettingsHeading, printSpeed(+Hint), darkness(+Hint), mediaType (+T/+D), printOrientation (+N/+I/+Indicator), defaultFont (+Id/+Height). Translations generated via scripts/add_locale_key.local.py.
LabelConfigPanel gains a section for print speed, darkness, media type, print orientation and default font. Empty inputs persist as undefined so absent fields stay absent in the generated output. Darkness preserves 0 as a valid value via parseIntOrUndef. Canvas shows a small badge in the top-right corner when print orientation is set to upside down, signalling the printer-side flip without rotating the design surface.
The CF handler parsed p[1] both via int() (for the parser-local cfHeight state) and via parseInt() (to detect explicit height for labelConfig. defaultFont). Both serve distinct purposes but the duplicate parse can be replaced by a single parseInt with NaN-aware fallback.
…tions
The empty option in the mediaMode/mediaType/printOrientation selects
previously reused presetCustom ("Custom"), which is the right semantic
for the dimension-preset select but not for "unset, use printer's own
default". Adds a dedicated label.printerDefault key in all 32 locales
and points the three empty-state options at it.
Using `??` to merge the patch into the current value collapsed two
distinct states: "this key was not in the patch" and "the user just
cleared this input". The latter passes `{ height: undefined }`, but
`undefined ?? current.height` falls through to the old value, so
clearing the height field had no effect on stored defaultFont. Replaces
`??` with an `in` check so an explicit `undefined` overrides current.
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive support for printer-specific settings, including print speed, darkness, media type, orientation, and default font configuration. These settings are integrated into the UI properties panel, ZPL generation, and parsing logic, with localized strings added across all supported languages. Feedback focuses on improving the user experience when configuring default fonts by allowing partial state updates in the UI and schema, ensuring robust ZPL parsing by trimming whitespace, and preventing invalid ZPL output for incomplete font definitions.
Replaces the nested defaultFont: { fontId, height } object with two
independent optional fields defaultFontId and defaultFontHeight. The
nested shape forced an all-or-nothing UI: typing one field at a time
either lost the partial input (deadlock) or required a fragile merge
helper that conflated 'absent' and 'cleared' states.
Flat fields let each input persist independently; the generator emits
^CF only when both are set. Removes mergeDefaultFont; tests updated
including a new pair that asserts ^CF is omitted on partial state.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This PR adds support for printer-specific ZPL settings (speed, darkness, media type, orientation, and default font) across the schema, UI, generator, and parser. It includes a new 'Printer settings' panel and an upside-down orientation indicator. Reviewer feedback suggests refining the ^CF command generation to support independent parameters and improving the robustness of MT and PO parsing against leading spaces.
The ^CF parameters are individually optional per Zebra spec: ^CF0 sets the font without changing the height, ^CF,30 sets the height without changing the font. Previously the generator required both fields and would silently drop a partial command on round-trip. Now emits whichever fields are set, with explicit round-trip tests for both partial forms.
No description provided.