summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/tray-icon-controller.ts25
1 files changed, 13 insertions, 12 deletions
diff --git a/gui/src/main/tray-icon-controller.ts b/gui/src/main/tray-icon-controller.ts
index f3333a2636..f4f3925f75 100644
--- a/gui/src/main/tray-icon-controller.ts
+++ b/gui/src/main/tray-icon-controller.ts
@@ -7,7 +7,6 @@ export type TrayIconType = 'unsecured' | 'securing' | 'secured';
export default class TrayIconController {
private animation?: KeyframeAnimation;
private iconImages: NativeImage[] = [];
- private monochromaticIconImages: NativeImage[] = [];
constructor(
tray: Tray,
@@ -19,7 +18,7 @@ export default class TrayIconController {
const initialFrame = this.targetFrame();
const animation = new KeyframeAnimation();
animation.speed = 100;
- animation.onFrame = (frameNumber) => tray.setImage(this.imageForFrame(frameNumber));
+ animation.onFrame = (frameNumber) => tray.setImage(this.iconImages[frameNumber]);
animation.play({ start: initialFrame, end: initialFrame });
this.animation = animation;
@@ -38,6 +37,7 @@ export default class TrayIconController {
set useMonochromaticIcon(useMonochromaticIcon: boolean) {
this.useMonochromaticIconValue = useMonochromaticIcon;
+ this.loadImages();
if (this.animation && !this.animation.isRunning) {
this.animation.play({ end: this.targetFrame() });
@@ -61,13 +61,20 @@ export default class TrayIconController {
const basePath = path.resolve(path.join(__dirname, '../../assets/images/menubar icons'));
const frames = Array.from({ length: 10 }, (_, i) => i + 1);
+ const suffix = this.imageSuffix();
+ const extension = process.platform === 'win32' ? 'ico' : 'png';
+
this.iconImages = frames.map((frame) =>
- nativeImage.createFromPath(path.join(basePath, `lock-${frame}.png`)),
+ nativeImage.createFromPath(path.join(basePath, `lock-${frame}${suffix}.${extension}`)),
);
+ }
- this.monochromaticIconImages = frames.map((frame) =>
- nativeImage.createFromPath(path.join(basePath, `lock-${frame}Template.png`)),
- );
+ private imageSuffix() {
+ if (this.useMonochromaticIconValue && process.platform === 'darwin') {
+ return 'Template';
+ } else {
+ return '';
+ }
}
private targetFrame(): number {
@@ -80,10 +87,4 @@ export default class TrayIconController {
return 8;
}
}
-
- private imageForFrame(frame: number): NativeImage {
- return this.useMonochromaticIconValue
- ? this.monochromaticIconImages[frame]
- : this.iconImages[frame];
- }
}