Tray-gated HTML preview flow - #1455
Conversation
Initial ivy support (squashed)
Deprecated Monocle, add support for Headless
# Conflicts: # build.xml
- Read preview/monocle prefs from live `TrayManager` when available, with `PrefsSearch` fallback for non-tray contexts - Treat Monocle as non-interactive for preview gating: when preview is enabled in headless/monocle mode, log and print directly. - Keep direct print routed through `PrintHtmlInstance` for consistency with preview-accepted printing
- Harden `PreviewHtmlInstance` lifecycle to avoid hangs and race failures: - cancel cleanly when loaded content has no body, - guard delayed preview-height updates when preview window is not yet available, - treat preview init/launch runtime failures as cancel and always release latches, - preserve interrupt status in delayed helper thread. - Replace reflection-based WebView peer-update in `AbstractHtmlInstance` with explicit JavaFX helper calls (`SceneHelper` + `NodeHelper`) for consistent resize behavior
Problem: - Browser uploads do not reliably provide trusted local file paths - HTML printed from path-less/plain payloads and couldn't resolve relative image assets Solution: - Added websocket method `printers.pickHtmlFile` - Exposed JS API helper `qz.printers.pickHtmlFile()` - Wired Pixel-tab `Upload a file...` HTML flow to use native JavaFX file chooser and store selected path for print - Updated dropped HTML print payload to use `format: 'html'` + `flavor: 'file'` with the selected `file://` path - Hardened `sample.html` drop-print payload handling for non-base64 values
1. When `Preview HTML Prints` is enabled: - Monocle preference is turned off (if enabled) - Monocle checkbox is unchecked and disabled 2. When Preview is disabled: - Monocle checkbox is re-enabled 3. When `Use Monocle for HTML` is enabled while Preview is on: - Preview preference is turned off - Preview checkbox is unchecked - A single consolidated warning is shown (policy + restart note)
This reverts commit 8a46845.
- Remove redundant `PrintHtmlInstance` class and its duplicate print/raster logic - Route preview-accepted HTML print directly to `WebApp.print(job, model)` - Route non-preview HTML print directly to `WebApp.print(job, model)`
- Replace `Ruler` orientation boolean with `javafx.geometry.Orientation` for clearer code - No behavior change intended, this is a readability change
| setDimensions(contentWidth, contentHeight); | ||
| } | ||
|
|
||
| enum UNIT { |
There was a problem hiding this comment.
| enum UNIT { | |
| enum UNIT { | |
| enum Unit { |
May also be redundant with PrintOptions.Unit.
| case MM: | ||
| setUnit(UNIT.MM); | ||
| } | ||
| } |
There was a problem hiding this comment.
PX is part of enum but never refernced here.
| heightProperty().addListener(evt -> draw()); | ||
| } | ||
|
|
||
| private boolean isVertical() { |
There was a problem hiding this comment.
This helper can now be refactored out.
|
|
||
| @Override | ||
| public double prefWidth(double height) { | ||
| if (isVertical()) return 20; |
|
|
||
| @Override | ||
| public double prefHeight(double width) { | ||
| if (!isVertical()) return 20; |
There was a problem hiding this comment.
Please replace with ternary like above.
| protected CountDownLatch captureLatch; | ||
|
|
||
| //listens for a Succeeded state to activate image capture | ||
| protected ChangeListener<Worker.State> stateListener = (ov, oldState, newState) -> { |
There was a problem hiding this comment.
This code is still redundant with WebApp.java.
|
@IdelsTak thank you for rebasing this against |
|
Okay, so @tresf, I have done heavy removal of duplications across When I started out in the last round I, however, found out exactly today what was the cause. (It was the timing of its With that identified, I was today able to gradually remove all the other related duplicate code. In my smoke tests and auto tests I didn't find any new regressions and the required html preview features all work as expected. |
|
Thanks. I will workshop the remaining items with @Vzor- at a future time as well as run comprehensive regression tests. |
|
Awesome! |
Changes made:
AbstractHtmlInstancePreviewHtmlInstancePreviewWindowRulertray.preview(ArgValue.TRAY_PREVIEW)Preview HTML PrintsPrintHTMLnow callsWebApp.print(job, model, options)WebAppnow decides preview vs direct print based on tray prefsheadlessorMonocle, preview UI is skipped and print proceeds directlyIconCachesingleton access (getInstance())PrintHtmlInstanceWebApp.print(job, model)sample.html/asset-handling changes were made but then reverted on @tresf's request and are thus not part of this PR