From 3bec760ee76a7c48accaef9b66d8fbd27d912140 Mon Sep 17 00:00:00 2001 From: anxuae Date: Tue, 12 Apr 2022 22:07:00 +0200 Subject: [PATCH] Add new variable 'url' to forge the QRCode url --- README.rst | 7 +++++-- pibooth_qrcode.py | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index decba12..623b7f9 100644 --- a/README.rst +++ b/README.rst @@ -35,7 +35,7 @@ Here below the new configuration options available in the `pibooth`_ configurati background = (0, 0, 0) # Optional text displayed close to the QR code - side_text = + side_text = # Offset (x, y) from location offset = (20, 40) @@ -55,7 +55,10 @@ The URL linked to the QR code can be define dynamically using some state variabl options. Available variables to forge the URL are: - **picture** : current picture filename -- **count** : current counters. You can access to values using ``{count.xxx}`` (see counters in configuration menu) +- **count** : current counters. You can access to values using ``{count.xxx}`` (see counters + in configuration menu) +- **url** : URL defined in the ``app.previous_picture_url`` attribute. This attribute can be + defined by another plugin. For instance, ``https://photos.google.com/share/AxFF4t56kiJiu89m/{picture}`` will generate:: diff --git a/pibooth_qrcode.py b/pibooth_qrcode.py index 361753c..4b5096b 100644 --- a/pibooth_qrcode.py +++ b/pibooth_qrcode.py @@ -11,7 +11,7 @@ import pibooth from pibooth.view.background import multiline_text_to_surfaces -__version__ = "1.0.1" +__version__ = "1.0.2" SECTION = 'QRCODE' @@ -130,7 +130,7 @@ def state_wait_do(app, win): win.surface.blit(text, rect) -@pibooth.hookimpl +@pibooth.hookimpl(trylast=True) def state_processing_exit(cfg, app): """ Generate the QR Code and store it in the application. @@ -143,7 +143,8 @@ def state_processing_exit(cfg, app): border=1) url_vars = {'picture': app.picture_filename, - 'count': app.count} + 'count': app.count, + 'url': getattr(app, 'previous_picture_url', None) or ''} qr.add_data(cfg.get(SECTION, 'prefix_url').format(**url_vars)) qr.make(fit=True)