Rework loading
@@ -124,7 +124,7 @@ public class BrowserHistoryTabComp extends SimpleComp {
|
||||
|
||||
var open = new IntroComp(
|
||||
"browserWelcomeEmpty",
|
||||
new LabelGraphic.CompGraphic(PrettyImageHelper.ofSpecificFixedSize("graphics/Hips.svg", 100, 122)));
|
||||
new LabelGraphic.CompGraphic(PrettyImageHelper.ofSpecificFixedSize("welcome/hips.svg", 100, 122)));
|
||||
open.setButtonGraphic(new LabelGraphic.IconGraphic("mdi2f-folder-open-outline"));
|
||||
open.setButtonAction(() -> {
|
||||
BrowserFullSessionModel.DEFAULT.openFileSystemAsync(
|
||||
|
||||
@@ -19,7 +19,13 @@ public class BrowserIconManager {
|
||||
|
||||
public static void loadIfNecessary(String s) {
|
||||
var res = AppMainWindow.get().displayScale().get() == 1.0 ? "24" : "40";
|
||||
var name = "browser/" + FilenameUtils.getBaseName(s) + "-" + res + ".png";
|
||||
AppImages.loadImage(AppResources.MAIN_MODULE, name, name);
|
||||
var key = "browser/" + FilenameUtils.getBaseName(s) + "-" + res + ".png";
|
||||
if (AppImages.hasImage(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AppResources.with(AppResources.MAIN_MODULE, key, file -> {
|
||||
AppImages.loadImage(file, key);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +82,7 @@ public class AppMainWindowContentComp extends SimpleComp {
|
||||
loadingAnimation.start();
|
||||
|
||||
// This allows for assigning logos even if AppImages has not been initialized yet
|
||||
var dir = "img/logo/";
|
||||
AppResources.with(AppResources.MAIN_MODULE, dir, path -> {
|
||||
AppResources.with(AppResources.MAIN_MODULE, "", path -> {
|
||||
var image = AppPrefs.get() != null
|
||||
&& AppPrefs.get().theme().getValue().isDark()
|
||||
? path.resolve("loading-160-dark.png")
|
||||
|
||||
@@ -79,7 +79,7 @@ public class AppDesktopIntegration {
|
||||
&& AppLogs.get().isWriteToSysout()
|
||||
&& Taskbar.isTaskbarSupported()) {
|
||||
try {
|
||||
var iconUrl = Main.class.getResourceAsStream("resources/img/logo/padded/logo_128x128.png");
|
||||
var iconUrl = Main.class.getResourceAsStream("resources/logo/padded/logo_128x128.png");
|
||||
if (iconUrl != null) {
|
||||
var awtIcon = ImageIO.read(iconUrl);
|
||||
Taskbar.getTaskbar().setIconImage(awtIcon);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.xpipe.app.core;
|
||||
|
||||
import io.xpipe.app.core.window.AppMainWindow;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
|
||||
@@ -31,53 +32,87 @@ public class AppImages {
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
if (images.size() > 0) {
|
||||
return;
|
||||
}
|
||||
loadBundledProviderIcons();
|
||||
loadOsIcons();
|
||||
loadWelcomeImages();
|
||||
loadMiscImages();
|
||||
loadLogos();
|
||||
}
|
||||
|
||||
TrackEvent.info("Loading images ...");
|
||||
for (var module : AppExtensionManager.getInstance().getContentModules()) {
|
||||
loadDirectory(module.getName(), "img", true);
|
||||
private static void loadBundledProviderIcons() {
|
||||
var exts = AppExtensionManager.getInstance().getContentModules();
|
||||
for (Module ext : exts) {
|
||||
AppResources.with(ext.getName(), "img/", basePath -> {
|
||||
var skipLarge = AppMainWindow.get().displayScale().get() == 1.0;
|
||||
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
var name = file.getFileName().toString();
|
||||
if (name.contains("-80") && skipLarge) {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
AppImages.loadImage(file, name);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadDirectory(String module, String dir, boolean loadImages) {
|
||||
var start = Instant.now();
|
||||
AppResources.with(module, dir, basePath -> {
|
||||
if (!Files.exists(basePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var simpleName = FilenameUtils.getExtension(module);
|
||||
String defaultPrefix = simpleName + ":";
|
||||
private static void loadOsIcons() {
|
||||
AppResources.with(AppResources.MAIN_MODULE, "os", basePath -> {
|
||||
var skipLarge = AppMainWindow.get().displayScale().get() == 1.0;
|
||||
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
var relativeFileName = FilenameUtils.separatorsToUnix(
|
||||
basePath.relativize(file).toString());
|
||||
var key = defaultPrefix + relativeFileName;
|
||||
if (images.containsKey(key)) {
|
||||
var name = file.getFileName().toString();
|
||||
if (name.contains("-40") && skipLarge) {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
if (loadImages) {
|
||||
images.put(key, loadImage(file));
|
||||
}
|
||||
AppImages.loadImage(file, "os/" + name);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
});
|
||||
var elapsed = Duration.between(start, Instant.now());
|
||||
TrackEvent.trace("Loaded images in " + module + ":" + dir + " in " + elapsed.toMillis() + " ms");
|
||||
}
|
||||
|
||||
public static void loadImage(String module, String key, String file) {
|
||||
AppResources.with(module, file, p -> {
|
||||
if (images.containsKey(key)) {
|
||||
return;
|
||||
}
|
||||
private static void loadWelcomeImages() {
|
||||
AppResources.with(AppResources.MAIN_MODULE, "welcome", basePath -> {
|
||||
var skipLarge = AppMainWindow.get().displayScale().get() == 1.0;
|
||||
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
var name = file.getFileName().toString();
|
||||
if (name.contains("-244") && skipLarge) {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
images.put(key, loadImage(p));
|
||||
AppImages.loadImage(file, "welcome/" + name);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private static void loadLogos() {
|
||||
AppResources.with(AppResources.MAIN_MODULE, "logo", basePath -> {
|
||||
Files.walkFileTree(basePath, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
var relativeFileName = FilenameUtils.separatorsToUnix(basePath.getParent().relativize(file).toString());
|
||||
AppImages.loadImage(file, relativeFileName);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private static void loadMiscImages() {
|
||||
AppResources.with(AppResources.MAIN_MODULE, "", basePath -> {
|
||||
loadImage(basePath.resolve("action.png"), "action.png");
|
||||
loadImage(basePath.resolve("error.png"), "error.png");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,7 +125,7 @@ public class AppImages {
|
||||
return true;
|
||||
}
|
||||
|
||||
var key = file.contains(":") ? file : "app:" + file;
|
||||
var key = file.contains(":") ? file.split(":", 2)[1] : file;
|
||||
if (images.containsKey(key)) {
|
||||
return true;
|
||||
}
|
||||
@@ -107,13 +142,12 @@ public class AppImages {
|
||||
return images.get(file);
|
||||
}
|
||||
|
||||
var key = file.contains(":") ? file : "app:" + file;
|
||||
|
||||
var key = file.contains(":") ? file.split(":", 2)[1] : file;
|
||||
if (images.containsKey(key)) {
|
||||
return images.get(key);
|
||||
}
|
||||
|
||||
TrackEvent.warn("Normal image " + key + " not found");
|
||||
TrackEvent.warn("Image " + key + " not found");
|
||||
return DEFAULT_IMAGE;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ public class AppTrayIcon {
|
||||
|
||||
var image =
|
||||
switch (OsType.ofLocal()) {
|
||||
case OsType.Windows ignored -> "img/logo/full/logo_16x16.png";
|
||||
case OsType.Linux ignored -> "img/logo/full/logo_24x24.png";
|
||||
case OsType.MacOs ignored -> "img/logo/padded/logo_24x24.png";
|
||||
case OsType.Windows ignored -> "logo/full/logo_16x16.png";
|
||||
case OsType.Linux ignored -> "logo/full/logo_24x24.png";
|
||||
case OsType.MacOs ignored -> "logo/padded/logo_24x24.png";
|
||||
};
|
||||
var url = AppResources.getResourceURL(AppResources.MAIN_MODULE, image).orElseThrow();
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class AppWindowStyle {
|
||||
stage.getIcons().clear();
|
||||
|
||||
// This allows for assigning logos even if AppImages has not been initialized yet
|
||||
var dir = OsType.ofLocal() == OsType.MACOS ? "img/logo/padded" : "img/logo/full";
|
||||
var dir = OsType.ofLocal() == OsType.MACOS ? "logo/padded" : "logo/full";
|
||||
AppResources.with(AppResources.MAIN_MODULE, dir, path -> {
|
||||
var size =
|
||||
switch (OsType.ofLocal()) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class OsLogoComp extends SimpleComp {
|
||||
}
|
||||
|
||||
if (ICONS.isEmpty()) {
|
||||
AppResources.with(AppResources.MAIN_MODULE, "img/os", file -> {
|
||||
AppResources.with(AppResources.MAIN_MODULE, "os", file -> {
|
||||
try (var list = Files.list(file)) {
|
||||
list.filter(path -> path.toString().endsWith(".png")
|
||||
&& !path.toString().endsWith(LINUX_DEFAULT_24)
|
||||
|
||||
@@ -92,7 +92,7 @@ public class StoreCreationMenu {
|
||||
|
||||
var actionMenu = categoryMenu("addMacro", "mdmz-miscellaneous_services", DataStoreCreationCategory.MACRO, null);
|
||||
var item = new MenuItem();
|
||||
item.setGraphic(PrettyImageHelper.ofFixedSize("app:shortcut/actionShortcut_icon.svg", 16, 16)
|
||||
item.setGraphic(PrettyImageHelper.ofFixedSize("action.png", 16, 16)
|
||||
.createRegion());
|
||||
item.textProperty().bind(AppI18n.observable("actionShortcut"));
|
||||
item.setOnAction(event -> {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class StoreIntroComp extends SimpleComp {
|
||||
@Override
|
||||
public Region createSimple() {
|
||||
var hub = new IntroComp("storeIntro", new LabelGraphic.NodeGraphic(() -> PrettyImageHelper.ofSpecificFixedSize(
|
||||
"graphics/Wave.svg", 80, 144)
|
||||
"welcome/wave.svg", 80, 144)
|
||||
.createRegion()));
|
||||
hub.setButtonAction(() -> {
|
||||
ScanDialog.showSingleAsync(DataStorage.get().local());
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package io.xpipe.app.icon;
|
||||
|
||||
import io.xpipe.app.core.AppCache;
|
||||
import io.xpipe.app.core.AppImages;
|
||||
import io.xpipe.app.core.AppProperties;
|
||||
import io.xpipe.app.core.AppResources;
|
||||
import io.xpipe.app.core.*;
|
||||
import io.xpipe.app.core.window.AppMainWindow;
|
||||
import io.xpipe.app.ext.ValidationException;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.*;
|
||||
|
||||
public class SystemIconManager {
|
||||
|
||||
@@ -346,7 +346,7 @@ public class DataStoreEntry extends StorageElement {
|
||||
|
||||
public String getEffectiveIconFile() {
|
||||
if (getValidity() == Validity.LOAD_FAILED) {
|
||||
return "disabled_icon.png";
|
||||
return "error.png";
|
||||
}
|
||||
|
||||
if (icon == null) {
|
||||
@@ -357,7 +357,7 @@ public class DataStoreEntry extends StorageElement {
|
||||
if (found.isPresent()) {
|
||||
return SystemIconManager.getAndLoadIconFile(found.get());
|
||||
} else {
|
||||
return "disabled_icon.png";
|
||||
return "error.png";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 593 B |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 835 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 647 B After Width: | Height: | Size: 647 B |
|
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 992 B |
|
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 156 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 754 B After Width: | Height: | Size: 754 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 927 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 832 B After Width: | Height: | Size: 832 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 714 B After Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 555 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 891 B After Width: | Height: | Size: 891 B |
|
Before Width: | Height: | Size: 760 B After Width: | Height: | Size: 760 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 495 B After Width: | Height: | Size: 495 B |
|
Before Width: | Height: | Size: 795 B After Width: | Height: | Size: 795 B |
|
Before Width: | Height: | Size: 818 B After Width: | Height: | Size: 818 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 626 B |
|
Before Width: | Height: | Size: 629 B After Width: | Height: | Size: 629 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 912 B |
|
Before Width: | Height: | Size: 963 B After Width: | Height: | Size: 963 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 930 B After Width: | Height: | Size: 930 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 755 B After Width: | Height: | Size: 755 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 960 B After Width: | Height: | Size: 960 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 763 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 740 B After Width: | Height: | Size: 740 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 963 B After Width: | Height: | Size: 963 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 485 B |
|
Before Width: | Height: | Size: 467 B After Width: | Height: | Size: 467 B |
|
Before Width: | Height: | Size: 823 B After Width: | Height: | Size: 823 B |
|
Before Width: | Height: | Size: 786 B After Width: | Height: | Size: 786 B |
|
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
|
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 285 B |
|
Before Width: | Height: | Size: 804 B After Width: | Height: | Size: 804 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 753 B After Width: | Height: | Size: 753 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 699 B After Width: | Height: | Size: 699 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 656 B After Width: | Height: | Size: 656 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |