Skip to content

Commit 6c15239

Browse files
committed
qtvco -qt_path: add functions to search for handler/ui paths
we want to support custom embedded qtvcp panels, so need to search paths. should refactor this function with the default search - but in a hurry...
1 parent bffd47d commit 6c15239

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

lib/python/qtvcp/qt_pstat.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,61 @@ def find_image_path(self,imagefile=''):
345345
LOG.verbose("Using default image path from: yellow<{}>".format(default))
346346
return default
347347

348+
def find_embed_panel_path(self, name):
349+
# look for custom ui file
350+
ui_fn = "{}.ui".format(name)
351+
local = []
352+
local.append( os.path.join(self.WORKINGDIR, 'qtvcp/panels',name, ui_fn))
353+
local.append( os.path.join(self.WORKINGDIR, ui_fn))
354+
defaultui = os.path.join(self.PANELDIR, name, ui_fn)
355+
356+
for localui in local:
357+
LOG.debug("(embed) Checking for .ui in: yellow<{}>".format(localui))
358+
if os.path.exists(localui):
359+
LOG.info("(embed) Using LOCAL ui file from: yellow<{}>".format(localui))
360+
XML = localui
361+
return XML
362+
# if no break
363+
else:
364+
LOG.debug("(embed) Checking for .ui in: yellow<{}>".format(defaultui))
365+
if os.path.exists(defaultui):
366+
LOG.debug("(embed) Using DEFAULT ui file from: yellow<{}>".format(defaultui))
367+
XML = defaultui
368+
return XML
369+
else:
370+
# error
371+
LOG.critical("(embed) No UI file found - Did you add the .ui name/path?")
372+
return True # error
373+
374+
def find_embed_handler_path(self, name):
375+
# look for custom handler files:
376+
handler_fn = "{}_handler.py".format(name)
377+
local = []
378+
# in standard folder
379+
local.append( os.path.join(self.WORKINGDIR, 'qtvcp/panels',name, handler_fn))
380+
# relative to configuration folder
381+
local.append( os.path.join(self.WORKINGDIR, handler_fn))
382+
# builtin panel folder
383+
default_handler_path = os.path.join(self.PANELDIR, name, handler_fn)
384+
385+
for local_handler_path in local:
386+
LOG.debug("(embed) Checking for handler file in: yellow<{}>".format(local_handler_path))
387+
if os.path.exists(local_handler_path):
388+
HANDLER = local_handler_path
389+
LOG.info("(embed) Using LOCAL handler file path: yellow<{}>".format(HANDLER))
390+
return HANDLER
391+
# if no break
392+
else:
393+
LOG.debug("(embed) Checking for default handler file in: yellow<{}>".format(default_handler_path))
394+
if os.path.exists(default_handler_path):
395+
HANDLER = default_handler_path
396+
LOG.debug("(embed) Using DEFAULT handler file path: yellow<{}>".format(HANDLER))
397+
return HANDLER
398+
else:
399+
HANDLER = None
400+
LOG.info("(embed) No handler file found.")
401+
return True
402+
348403
def find_screen_dirs(self):
349404
dirs = next(os.walk(self.SCREENDIR))[1]
350405
return dirs

0 commit comments

Comments
 (0)