Add new printing options, change image conversion for Brother QL

printers
This commit is contained in:
n07070
2026-11-12 17:26:50 +01:00
parent d254fa0d32
commit 72e6e93337
6 changed files with 80 additions and 24 deletions

View File

@@ -16,7 +16,7 @@ class Web:
self.print_queue = print_queue
self.app = app
def print_sms(self, texte, sign: str) -> bool:
def print_sms(self, texte, sign: str, do_cut: bool) -> bool:
"""
Get text and a signature, prints the text and cuts after that.
"""
@@ -29,14 +29,18 @@ class Web:
# are added back to back, another task could be
# inserted between the two.
sms = self.print_queue.enqueue(TextTask(content=texte, signature=sign))
cut = self.print_queue.enqueue(CutTask())
self.app.logger.info("Added a SMS task at position %s", sms)
if do_cut:
cut = self.print_queue.enqueue(CutTask())
self.app.logger.info("Added a CUT task at position %s", cut)
except Exception as e:
self.app.logger.error(e)
raise RuntimeError("Could not add SMS to queue, " + str(e)) from e
self.app.logger.info("Added two new tasks at position %s and %s", sms, cut)
return True
def print_image(self, image, sign: str) -> bool:
def print_image(self, image, sign: str, do_cut: bool, process_image: bool) -> bool:
"""
Get an image and a signature, prints the image and cuts after that.
"""
@@ -56,16 +60,17 @@ class Web:
secure_filename(image.filename),
),
signature=sign,
process=True,
process=process_image,
)
)
self.app.logger.info("Added a IMG task at position %s", img)
cut = self.print_queue.enqueue(CutTask())
if do_cut:
cut = self.print_queue.enqueue(CutTask())
self.app.logger.info("Added a CUT task at position %s", cut)
except Exception as e:
raise RuntimeError("Could not add IMG to queue" + str(e)) from e
self.app.logger.info("Added two new tasks at position %s and %s", img, cut)
return True
# def login(self, username: str, password: str) -> bool: