diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/WebAppConfig.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/WebAppConfig.java index 80a65d40a4..44d27b905c 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/WebAppConfig.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/WebAppConfig.java @@ -37,12 +37,13 @@ public class WebAppConfig { private static final String DEFAULT_THEME = THEME_NAME_BRIGHT; private static final String DEFAULT_ICONIFY = "false"; - + private static final String DEFAULT_INLINE_SVG = "false"; private static final String DEFAULT_WEB_AUDIO = "false"; private String defaultSitemap = DEFAULT_SITEMAP; private String theme = DEFAULT_THEME; private boolean iconify = Boolean.parseBoolean(DEFAULT_ICONIFY); + private boolean inlineSvg = Boolean.parseBoolean(DEFAULT_INLINE_SVG); private boolean webAudio = Boolean.parseBoolean(DEFAULT_WEB_AUDIO); private List cssClassList = new ArrayList<>(); @@ -90,6 +91,7 @@ public void applyConfig(Map configProps) { theme = DEFAULT_THEME; } iconify = "true".equalsIgnoreCase((String) configProps.getOrDefault("enableIconify", DEFAULT_ICONIFY)); + inlineSvg = "true".equalsIgnoreCase((String) configProps.getOrDefault("inlineSvg", DEFAULT_INLINE_SVG)); webAudio = "true".equalsIgnoreCase((String) configProps.getOrDefault("webAudio", DEFAULT_WEB_AUDIO)); applyCssClasses(configProps); @@ -115,6 +117,10 @@ public boolean isIconifyEnabled() { return iconify; } + public boolean isInlineSvgEnabled() { + return inlineSvg; + } + public boolean isWebAudio() { return webAudio; } diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java index 5c0de02802..5a5ef0be2c 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/PageRenderer.java @@ -116,6 +116,7 @@ public StringBuilder processPage(String id, String sitemap, String label, EList< snippet = snippet.replace("%sitemap%", sitemap); snippet = snippet.replace("%htmlclass%", config.getCssClassList()); snippet = snippet.replace("%icon_type%", ICON_TYPE); + snippet = snippet.replace("%inline%", config.isInlineSvgEnabled() ? "true" : "false"); snippet = snippet.replace("%theme%", config.getTheme()); snippet = snippet.replace("%sitemapquery%", String.format("?sitemap=%s", sitemap)); snippet = snippet.replace("%primarycolor%", PRIMARY_COLOR); diff --git a/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/config/config.xml index 1c55eeed5a..f045147678 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/config/config.xml @@ -25,6 +25,20 @@ true + + + If enabled, any SVG icon provided by the openHAB icon server will automatically be converted to an + inline SVG in the WEB page, allowing control of its color with the sitemap widget property "iconcolor" in + the case + where the SVG icon sets "currentColor" as the fill color. Note that this will work with custom SVG icons but not + with all the packaged icons from the classic iconset since they are defined with a hard-coded color palette. This + feature is disabled by default. + + + + + false + If enabled, the UI will render iconify icons directly by downloading them from the Internet and caching diff --git a/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/i18n/basic.properties b/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/i18n/basic.properties index ecfc5b82eb..9973707d63 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/i18n/basic.properties +++ b/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/i18n/basic.properties @@ -16,6 +16,10 @@ ui.config.basic.enableIcons.label = Enable Icons ui.config.basic.enableIcons.description = Defines whether UI renders icons for the widgets or not. ui.config.basic.enableIcons.option.true = Enable ui.config.basic.enableIcons.option.false = Disable +ui.config.basic.inlineSvg.label = Inline SVG +ui.config.basic.inlineSvg.description = If enabled, any SVG icon provided by the openHAB icon server will automatically be converted to an inline SVG in the WEB page, allowing control of its color with the sitemap widget property "iconcolor" in the case where the SVG icon sets "currentColor" as the fill color. Note that this will work with custom SVG icons but not with all the packaged icons from the classic iconset since they are defined with a hard-coded color palette. This feature is disabled by default. +ui.config.basic.inlineSvg.option.true = Enable +ui.config.basic.inlineSvg.option.false = Disable ui.config.basic.theme.label = Theme ui.config.basic.theme.description = Defines the UI theme. ui.config.basic.theme.option.bright = Bright diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/main.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/main.html index 43d6e2b98f..bbe93bf1d4 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/main.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/main.html @@ -69,7 +69,7 @@ - +