Skip to content

Commit

Permalink
Merge pull request #3382 from lusarz/refactor-bisq-app-image-util
Browse files Browse the repository at this point in the history
Refactor BisqApp - move icon load into ImageUtil
  • Loading branch information
ripcurlx authored Oct 14, 2019
2 parents a5aea5a + 23877d4 commit 94b12a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
13 changes: 1 addition & 12 deletions desktop/src/main/java/bisq/desktop/app/BisqApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,7 @@ private void setupStage(Scene scene) {
stage.setScene(scene);
stage.setMinWidth(MIN_WINDOW_WIDTH);
stage.setMinHeight(MIN_WINDOW_HEIGHT);

// on Windows the title icon is also used as task bar icon in a larger size
// on Linux no title icon is supported but also a large task bar icon is derived from that title icon
String iconPath;
if (Utilities.isOSX())
iconPath = ImageUtil.isRetina() ? "/images/[email protected]" : "/images/window_icon.png";
else if (Utilities.isWindows())
iconPath = "/images/task_bar_icon_windows.png";
else
iconPath = "/images/task_bar_icon_linux.png";

stage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));
stage.getIcons().add(ImageUtil.getApplicationIconImage());

// make the UI visible
stage.show();
Expand Down
14 changes: 14 additions & 0 deletions desktop/src/main/java/bisq/desktop/util/ImageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import bisq.core.locale.Country;

import bisq.common.util.Utilities;

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

Expand All @@ -40,6 +42,18 @@ public static ImageView getImageViewById(String id) {
return imageView;
}

public static Image getApplicationIconImage () {
String iconPath;
if (Utilities.isOSX())
iconPath = ImageUtil.isRetina() ? "/images/[email protected]" : "/images/window_icon.png";
else if (Utilities.isWindows())
iconPath = "/images/task_bar_icon_windows.png";
else
iconPath = "/images/task_bar_icon_linux.png";

return getImageByUrl(iconPath);
}

private static Image getImageByUrl(String url) {
return new Image(ImageUtil.class.getResourceAsStream(url));
}
Expand Down

0 comments on commit 94b12a7

Please sign in to comment.