forked from AG_QGIS/Plugin_SN_Basis
Wrappe modular aufgebaut, Tests erfolgreich, Menüleiste und Werzeugleiste werden eingetragen (QT6 und QT5)- (Es fehlen noch Fachplugins, um zu prüfen, ob es auch wirklich in QGIS geht)
This commit is contained in:
27
functions/ly_style_wrapper.py
Normal file
27
functions/ly_style_wrapper.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# layer/style.py
|
||||
|
||||
from sn_basis.functions.ly_existence_wrapper import layer_exists
|
||||
from sn_basis.functions.sys_wrapper import (
|
||||
get_plugin_root,
|
||||
join_path,
|
||||
file_exists,
|
||||
)
|
||||
|
||||
|
||||
def apply_style(layer, style_name: str) -> bool:
|
||||
if not layer_exists(layer):
|
||||
return False
|
||||
|
||||
style_path = join_path(get_plugin_root(), "styles", style_name)
|
||||
if not file_exists(style_path):
|
||||
return False
|
||||
|
||||
try:
|
||||
ok, _ = layer.loadNamedStyle(style_path)
|
||||
if ok:
|
||||
getattr(layer, "triggerRepaint", lambda: None)()
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return False
|
||||
Reference in New Issue
Block a user