2023-05-01 23:23:43 +02:00
|
|
|
import { BrowserWindow, Tray } from "electron";
|
2023-05-01 23:31:37 +02:00
|
|
|
import { getMenu } from "./menu";
|
2019-10-30 21:43:52 +01:00
|
|
|
|
2023-05-01 23:23:43 +02:00
|
|
|
let tray: Tray;
|
|
|
|
|
|
|
|
export const addTray = function (mainWindow: BrowserWindow, options = { icon: "" }) {
|
2019-10-30 21:43:52 +01:00
|
|
|
tray = new Tray(options.icon);
|
2022-08-07 16:05:48 +02:00
|
|
|
tray.setIgnoreDoubleClickEvents(true);
|
|
|
|
tray.setToolTip("Tidal-hifi");
|
|
|
|
|
|
|
|
const menu = getMenu(mainWindow);
|
|
|
|
|
|
|
|
tray.setContextMenu(menu);
|
2023-01-22 20:51:38 +01:00
|
|
|
|
|
|
|
tray.on("click", function () {
|
2023-04-22 20:51:20 +02:00
|
|
|
if (mainWindow.isVisible()) {
|
|
|
|
if (!mainWindow.isFocused()) {
|
|
|
|
mainWindow.focus();
|
|
|
|
} else {
|
|
|
|
mainWindow.hide();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mainWindow.show();
|
|
|
|
}
|
2023-01-22 20:51:38 +01:00
|
|
|
});
|
2019-10-30 21:43:52 +01:00
|
|
|
};
|
|
|
|
|
2023-05-01 23:23:43 +02:00
|
|
|
export const refreshTray = function (mainWindow: BrowserWindow) {
|
2020-10-07 20:10:31 +02:00
|
|
|
if (!tray) {
|
2023-05-01 23:23:43 +02:00
|
|
|
addTray(mainWindow);
|
2021-06-17 20:37:14 +02:00
|
|
|
}
|
2019-10-30 21:43:52 +01:00
|
|
|
};
|