use smaller shared stage icon to reduce memory usage

This commit is contained in:
Craig Raw 2022-02-11 12:04:51 +02:00
parent cc31b5b78e
commit 9ec57b1ef6
3 changed files with 12 additions and 2 deletions

View file

@ -92,6 +92,8 @@ public class AppServices {
private TrayManager trayManager; private TrayManager trayManager;
private static Image windowIcon;
private static final BooleanProperty onlineProperty = new SimpleBooleanProperty(false); private static final BooleanProperty onlineProperty = new SimpleBooleanProperty(false);
private ExchangeSource.RatesService ratesService; private ExchangeSource.RatesService ratesService;
@ -498,7 +500,7 @@ public class AppServices {
stage.setMinWidth(650); stage.setMinWidth(650);
stage.setMinHeight(708); stage.setMinHeight(708);
stage.setScene(scene); stage.setScene(scene);
stage.getIcons().add(new Image(MainApp.class.getResourceAsStream("/image/sparrow-large.png"))); stage.getIcons().add(getWindowIcon());
appController.initializeView(); appController.initializeView();
stage.show(); stage.show();
@ -509,6 +511,14 @@ public class AppServices {
} }
} }
private static Image getWindowIcon() {
if(windowIcon == null) {
windowIcon = new Image(MainApp.class.getResourceAsStream("/image/sparrow-icon.png"));
}
return windowIcon;
}
public static boolean isReducedWindowHeight(Node node) { public static boolean isReducedWindowHeight(Node node) {
return (node.getScene() != null && node.getScene().getWindow().getHeight() < 768); return (node.getScene() != null && node.getScene().getWindow().getHeight() < 768);
} }
@ -694,7 +704,7 @@ public class AppServices {
public static void setStageIcon(Window window) { public static void setStageIcon(Window window) {
Stage stage = (Stage)window; Stage stage = (Stage)window;
stage.getIcons().add(new Image(AppServices.class.getResourceAsStream("/image/sparrow-large.png"))); stage.getIcons().add(getWindowIcon());
if(stage.getScene() != null && Config.get().getTheme() == Theme.DARK) { if(stage.getScene() != null && Config.get().getTheme() == Theme.DARK) {
stage.getScene().getStylesheets().add(AppServices.class.getResource("darktheme.css").toExternalForm()); stage.getScene().getStylesheets().add(AppServices.class.getResource("darktheme.css").toExternalForm());

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB