Skip to content

Commit 312e4ee

Browse files
committed
feat: add app icons
1 parent c746513 commit 312e4ee

13 files changed

Lines changed: 86 additions & 1 deletion

File tree

‎.gitattributes‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.png filter=lfs diff=lfs merge=lfs -text
2+
*.icns filter=lfs diff=lfs merge=lfs -text
3+
*.ico filter=lfs diff=lfs merge=lfs -text

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
src/main/resources/images/icons/app.iconset/
2+
13
# Compiled class file
24
*.class
35

@@ -107,4 +109,4 @@ Backups.backupdb
107109
.MobileBackups
108110
.MobileBackups.trash
109111
MobileBackups.trash
110-
tmbootpicker.efi
112+
tmbootpicker.efi

‎src/main/java/com/DesktopApplicationClientJava/Program.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import com.DesktopApplicationClientJava.session.Session;
77
import com.DesktopApplicationClientJava.utils.ControllerWiring;
88
import java.io.IOException;
9+
import java.io.InputStream;
10+
import java.util.List;
911
import javafx.application.Application;
1012
import javafx.fxml.FXMLLoader;
1113
import javafx.scene.Parent;
1214
import javafx.scene.Scene;
15+
import javafx.scene.image.Image;
1316
import javafx.stage.Stage;
1417

1518
public class Program extends Application {
@@ -20,6 +23,9 @@ public class Program extends Application {
2023
private static final double WINDOW_WIDTH = 800.0;
2124
private static final double WINDOW_HEIGHT = 600.0;
2225

26+
private static final String ICON_BASE = "/images/icons/png/app-";
27+
private static final List<Integer> ICON_SIZES = List.of(16, 32, 48, 64, 128, 256);
28+
2329
private final Session session = new Session();
2430
private final ApiClient apiClient = new ApiClient(session);
2531
private final ServiceRegistry services = createServices();
@@ -43,6 +49,7 @@ public void start(Stage stage) throws IOException {
4349
Parent root = loader.load();
4450
Scene scene = new Scene(root);
4551
loadStyleSheet(scene, "/styles.css");
52+
loadIcons(stage);
4653

4754
stage.setScene(scene);
4855
stage.setTitle("Госхрон" + (MOCK_DATA ? " [MOCK]" : ""));
@@ -65,4 +72,16 @@ private void loadStyleSheet(Scene scene, String path) {
6572
scene.getStylesheets().add(url.toExternalForm());
6673
}
6774
}
75+
76+
private void loadIcons(Stage stage) {
77+
for (int size : ICON_SIZES) {
78+
try (InputStream in = getClass().getResourceAsStream(ICON_BASE + size + ".png")) {
79+
if (in != null) {
80+
stage.getIcons().add(new Image(in));
81+
}
82+
} catch (IOException e) {
83+
System.err.println(e);
84+
}
85+
}
86+
}
6887
}

‎src/main/resources/images/app.png‎

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:f8a54b0989a7b9c13eab3184b62b9dc8caaba7548c5783caa9a606c38d2bffba
3+
size 1008340
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:4f9171af9bd2b73308dea604f361d9f53724227c1849ede7332049ea2e40cbd1
3+
size 370070
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)