mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ui: use old 128x128 png icon for application window on Linux if svg isn't specified for compatibility (IDEA-199662)
This commit is contained in:
@@ -45,6 +45,9 @@ public abstract class ApplicationInfoEx extends ApplicationInfo {
|
||||
|
||||
public abstract String getSmallIconUrl();
|
||||
|
||||
@Nullable
|
||||
public abstract String getBigIconUrl();
|
||||
|
||||
@Nullable
|
||||
public abstract String getApplicationSvgIconUrl();
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx {
|
||||
@SuppressWarnings("UseJBColor") private Color mySplashTextColor = new Color(0, 35, 135); // idea blue
|
||||
private String myIconUrl = "/icon.png";
|
||||
private String mySmallIconUrl = "/icon_small.png";
|
||||
private String myBigIconUrl;
|
||||
private String mySvgIconUrl;
|
||||
private String mySvgEapIconUrl;
|
||||
private String myToolWindowIconUrl = "/toolwindows/toolWindowProject.png";
|
||||
@@ -383,6 +384,12 @@ public class ApplicationInfoImpl extends ApplicationInfoEx {
|
||||
return mySmallIconUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getBigIconUrl() {
|
||||
return myBigIconUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getApplicationSvgIconUrl() {
|
||||
@@ -746,6 +753,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx {
|
||||
if (iconElement != null) {
|
||||
myIconUrl = iconElement.getAttributeValue(ATTRIBUTE_SIZE32);
|
||||
mySmallIconUrl = iconElement.getAttributeValue(ATTRIBUTE_SIZE16);
|
||||
myBigIconUrl = iconElement.getAttributeValue(ATTRIBUTE_SIZE128, (String)null);
|
||||
final String toolWindowIcon = iconElement.getAttributeValue(ATTRIBUTE_SIZE12);
|
||||
if (toolWindowIcon != null) {
|
||||
myToolWindowIconUrl = toolWindowIcon;
|
||||
|
||||
@@ -80,18 +80,9 @@ public class AppUIUtil {
|
||||
List<Image> images = ContainerUtil.newArrayListWithCapacity(3);
|
||||
|
||||
if (SystemInfo.isUnix) {
|
||||
String svgIconUrl = appInfo.getApplicationSvgIconUrl();
|
||||
if (svgIconUrl != null) {
|
||||
URL url = AppUIUtil.class.getResource(svgIconUrl);
|
||||
try {
|
||||
Image svgIcon = SVGLoader.load(url, AppUIUtil.class.getResourceAsStream(svgIconUrl), JBUI.pixScale(window) * 128, JBUI.pixScale(window) * 128);
|
||||
if (svgIcon != null) {
|
||||
images.add(svgIcon);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info("Cannot load svg application icon from " + svgIconUrl, e);
|
||||
}
|
||||
Image svgIcon = loadApplicationIcon(window, 128, appInfo.getBigIconUrl());
|
||||
if (svgIcon != null) {
|
||||
images.add(svgIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +107,29 @@ public class AppUIUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Image loadApplicationIcon(@NotNull Window window, int size, @Nullable String fallbackImageResourcePath) {
|
||||
String svgIconUrl = ApplicationInfoImpl.getShadowInstance().getApplicationSvgIconUrl();
|
||||
if (svgIconUrl != null) {
|
||||
URL url = AppUIUtil.class.getResource(svgIconUrl);
|
||||
try {
|
||||
return
|
||||
SVGLoader.load(url, AppUIUtil.class.getResourceAsStream(svgIconUrl), JBUI.pixScale(window) * size, JBUI.pixScale(window) * size);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info("Cannot load svg application icon from " + svgIconUrl, e);
|
||||
}
|
||||
}
|
||||
else if (fallbackImageResourcePath != null) {
|
||||
Image image = ImageLoader.loadFromResource(fallbackImageResourcePath);
|
||||
if (image instanceof JBHiDPIScaledImage) {
|
||||
return ((JBHiDPIScaledImage)image).getDelegate();
|
||||
}
|
||||
return image;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void invokeLaterIfProjectAlive(@NotNull Project project, @NotNull Runnable runnable) {
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application.isDispatchThread()) {
|
||||
|
||||
Reference in New Issue
Block a user