mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-10-15 18:06:21 +02:00
transitioning to ts
This commit is contained in:
33
src/scripts/tray.ts
Normal file
33
src/scripts/tray.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { BrowserWindow, Tray } from "electron";
|
||||
|
||||
const { getMenu } = require("./menu");
|
||||
|
||||
let tray: Tray;
|
||||
|
||||
export const addTray = function (mainWindow: BrowserWindow, options = { icon: "" }) {
|
||||
tray = new Tray(options.icon);
|
||||
tray.setIgnoreDoubleClickEvents(true);
|
||||
tray.setToolTip("Tidal-hifi");
|
||||
|
||||
const menu = getMenu(mainWindow);
|
||||
|
||||
tray.setContextMenu(menu);
|
||||
|
||||
tray.on("click", function () {
|
||||
if (mainWindow.isVisible()) {
|
||||
if (!mainWindow.isFocused()) {
|
||||
mainWindow.focus();
|
||||
} else {
|
||||
mainWindow.hide();
|
||||
}
|
||||
} else {
|
||||
mainWindow.show();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const refreshTray = function (mainWindow: BrowserWindow) {
|
||||
if (!tray) {
|
||||
addTray(mainWindow);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user