|
23 | 23 | from .settings import settings |
24 | 24 | from .network import NetworkError |
25 | 25 | from .image import Extent, Image, Mask, Bounds, DummyImage |
26 | | -from .client import Client, ClientMessage, ClientEvent, ClientOutput, is_style_supported |
| 26 | +from .client import ( |
| 27 | + Client, |
| 28 | + ClientMessage, |
| 29 | + ClientEvent, |
| 30 | + ClientOutput, |
| 31 | + is_style_supported, |
| 32 | + ResizeCommand, |
| 33 | +) |
27 | 34 | from .client import filter_supported_styles, resolve_arch |
28 | 35 | from .custom_workflow import CustomWorkspace, WorkflowCollection, CustomGenerationMode |
29 | 36 | from .document import Document, KritaDocument |
@@ -590,7 +597,10 @@ def handle_message(self, message: ClientMessage): |
590 | 597 | self.progress_kind = ProgressKind.upload |
591 | 598 | self.progress = message.progress |
592 | 599 | elif message.event is ClientEvent.output: |
593 | | - self.custom.show_output(message.result) |
| 600 | + if isinstance(message.result, ResizeCommand): |
| 601 | + self._apply_resize_command(message.result, job) |
| 602 | + else: |
| 603 | + self.custom.show_output(message.result) |
594 | 604 | elif message.event is ClientEvent.finished: |
595 | 605 | if message.error: # successful jobs may have encountered some warnings |
596 | 606 | self.report_error(Error.from_string(message.error, ErrorKind.warning)) |
@@ -630,6 +640,9 @@ def _finish_job(self, job: Job, event: ClientEvent): |
630 | 640 | self.jobs.notify_cancelled(job) |
631 | 641 | self.progress = 0 |
632 | 642 |
|
| 643 | + def _apply_resize_command(self, cmd: ResizeCommand, job: Job): |
| 644 | + job.params.resize_canvas = cmd.resize_canvas |
| 645 | + |
633 | 646 | def update_preview(self): |
634 | 647 | if selection := self.jobs.selection: |
635 | 648 | self.show_preview(selection[0].job, selection[0].image) |
@@ -673,6 +686,9 @@ def apply_result( |
673 | 686 | region_behavior=ApplyRegionBehavior.layer_group, |
674 | 687 | prefix="", |
675 | 688 | ): |
| 689 | + if params.resize_canvas and self.document.extent != image.extent: |
| 690 | + self.document.resize_canvas(*image.extent) |
| 691 | + |
676 | 692 | bounds = Bounds(*params.bounds.offset, *image.extent) |
677 | 693 | if len(params.regions) == 0 or region_behavior is ApplyRegionBehavior.none: |
678 | 694 | if behavior is ApplyBehavior.replace: |
|
0 commit comments