From e1dcd7d4edc9cdbfcca1b1488af61e5fdf4ce976 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 29 Sep 2023 13:02:30 -0500 Subject: [PATCH] Add support for custom header logo image within assets dir should avoid external URL for header logo where possible --- .gitignore | 1 + wuttapos/views/base.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a7479fe..6504721 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ WuttaPOS.egg-info/ +wuttapos/assets/custom_header_logo.png diff --git a/wuttapos/views/base.py b/wuttapos/views/base.py index 827970e..5536a26 100644 --- a/wuttapos/views/base.py +++ b/wuttapos/views/base.py @@ -24,6 +24,10 @@ WuttaPOS - flet views (base class) """ +import os + +from rattail.files import resource_path + import flet as ft from wuttapos.controls.header import WuttaHeader @@ -66,9 +70,17 @@ class WuttaView(ft.View): pass def make_logo_image(self, **kwargs): - logo = self.config.get('wuttapos', 'header.logo') - if not logo: + + # we have a default header logo, but prefer custom if present + custom = resource_path('wuttapos:assets/custom_header_logo.png') + if os.path.exists(custom): + logo = '/custom_header_logo.png' + else: logo = '/header_logo.png' + + # but config can override in any case + logo = self.config.get('wuttapos', 'header.logo', default=logo) + kwargs.setdefault('height', 100) return ft.Image(src=logo, **kwargs)