Add support for custom header logo image within assets dir

should avoid external URL for header logo where possible
This commit is contained in:
Lance Edgar 2023-09-29 13:02:30 -05:00
parent cd392fa432
commit e1dcd7d4ed
2 changed files with 15 additions and 2 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
WuttaPOS.egg-info/ WuttaPOS.egg-info/
wuttapos/assets/custom_header_logo.png

View file

@ -24,6 +24,10 @@
WuttaPOS - flet views (base class) WuttaPOS - flet views (base class)
""" """
import os
from rattail.files import resource_path
import flet as ft import flet as ft
from wuttapos.controls.header import WuttaHeader from wuttapos.controls.header import WuttaHeader
@ -66,9 +70,17 @@ class WuttaView(ft.View):
pass pass
def make_logo_image(self, **kwargs): 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' logo = '/header_logo.png'
# but config can override in any case
logo = self.config.get('wuttapos', 'header.logo', default=logo)
kwargs.setdefault('height', 100) kwargs.setdefault('height', 100)
return ft.Image(src=logo, **kwargs) return ft.Image(src=logo, **kwargs)