mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-08-03 11:31:20 +02:00
Feature/4.1.0 (#156)
* added protocol handler * Switched icon strategies to fix bugs with icons * fixed tray icon issues * fixed about :) * Fixed playback, mpris and API issues
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const { Menu, app } = require("electron");
|
||||
const { showSettingsWindow } = require("./settings");
|
||||
const isMac = process.platform === "darwin";
|
||||
const { name } = require("./../constants/values");
|
||||
|
||||
const settingsMenuEntry = {
|
||||
label: "Settings",
|
||||
@@ -15,92 +16,102 @@ const quitMenuEntry = {
|
||||
click() {
|
||||
app.exit(0);
|
||||
},
|
||||
accelerator: "Control+Q"
|
||||
accelerator: "Control+Q",
|
||||
};
|
||||
|
||||
const mainMenu = [
|
||||
...(isMac
|
||||
? [
|
||||
{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
{ role: "about" },
|
||||
settingsMenuEntry,
|
||||
{ type: "separator" },
|
||||
{ role: "services" },
|
||||
{ type: "separator" },
|
||||
{ role: "hide" },
|
||||
{ role: "hideothers" },
|
||||
{ role: "unhide" },
|
||||
{ type: "separator" },
|
||||
quitMenuEntry,
|
||||
],
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: "File",
|
||||
submenu: [settingsMenuEntry, isMac ? { role: "close" } : quitMenuEntry],
|
||||
},
|
||||
{
|
||||
label: "Edit",
|
||||
submenu: [
|
||||
{ role: "undo" },
|
||||
{ role: "redo" },
|
||||
{ type: "separator" },
|
||||
{ role: "cut" },
|
||||
{ role: "copy" },
|
||||
{ role: "paste" },
|
||||
...(isMac
|
||||
? [
|
||||
{ role: "pasteAndMatchStyle" },
|
||||
{ role: "delete" },
|
||||
{ role: "selectAll" },
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: "Speech",
|
||||
submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }],
|
||||
},
|
||||
]
|
||||
: [{ role: "delete" }, { type: "separator" }, { role: "selectAll" }]),
|
||||
{ type: "separator" },
|
||||
settingsMenuEntry,
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "View",
|
||||
submenu: [
|
||||
{ role: "reload" },
|
||||
{ role: "forcereload" },
|
||||
{ type: "separator" },
|
||||
{ role: "resetzoom" },
|
||||
{ role: "zoomin" },
|
||||
{ role: "zoomout" },
|
||||
{ type: "separator" },
|
||||
{ role: "togglefullscreen" },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Window",
|
||||
submenu: [
|
||||
{ role: "minimize" },
|
||||
...(isMac
|
||||
? [{ type: "separator" }, { role: "front" }, { type: "separator" }, { role: "window" }]
|
||||
: [{ role: "close" }]),
|
||||
],
|
||||
},
|
||||
settingsMenuEntry,
|
||||
{
|
||||
label: "About",
|
||||
click() {
|
||||
showSettingsWindow("about");
|
||||
const menuModule = {};
|
||||
|
||||
menuModule.getMenu = function (mainWindow) {
|
||||
const toggleWindow = {
|
||||
label: "Toggle Window",
|
||||
click: function () {
|
||||
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
const menuModule = { mainMenu };
|
||||
const mainMenu = [
|
||||
...(isMac
|
||||
? [
|
||||
{
|
||||
label: name,
|
||||
submenu: [
|
||||
{ role: "about" },
|
||||
settingsMenuEntry,
|
||||
{ type: "separator" },
|
||||
{ role: "services" },
|
||||
{ type: "separator" },
|
||||
{ role: "hide" },
|
||||
{ role: "hideothers" },
|
||||
{ role: "unhide" },
|
||||
{ type: "separator" },
|
||||
quitMenuEntry,
|
||||
],
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: "File",
|
||||
submenu: [settingsMenuEntry, isMac ? { role: "close" } : quitMenuEntry],
|
||||
},
|
||||
{
|
||||
label: "Edit",
|
||||
submenu: [
|
||||
{ role: "undo" },
|
||||
{ role: "redo" },
|
||||
{ type: "separator" },
|
||||
{ role: "cut" },
|
||||
{ role: "copy" },
|
||||
{ role: "paste" },
|
||||
...(isMac
|
||||
? [
|
||||
{ role: "pasteAndMatchStyle" },
|
||||
{ role: "delete" },
|
||||
{ role: "selectAll" },
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: "Speech",
|
||||
submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }],
|
||||
},
|
||||
]
|
||||
: [{ role: "delete" }, { type: "separator" }, { role: "selectAll" }]),
|
||||
{ type: "separator" },
|
||||
settingsMenuEntry,
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "View",
|
||||
submenu: [
|
||||
{ role: "reload" },
|
||||
{ role: "forcereload" },
|
||||
{ type: "separator" },
|
||||
{ role: "resetzoom" },
|
||||
{ role: "zoomin" },
|
||||
{ role: "zoomout" },
|
||||
{ type: "separator" },
|
||||
{ role: "togglefullscreen" },
|
||||
{ role: "toggledevtools" },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Window",
|
||||
submenu: [
|
||||
{ role: "minimize" },
|
||||
toggleWindow,
|
||||
...(isMac
|
||||
? [{ type: "separator" }, { role: "front" }, { type: "separator" }, { role: "window" }]
|
||||
: [{ role: "close" }]),
|
||||
],
|
||||
},
|
||||
settingsMenuEntry,
|
||||
{
|
||||
label: "About",
|
||||
click() {
|
||||
showSettingsWindow("about");
|
||||
},
|
||||
},
|
||||
toggleWindow,
|
||||
];
|
||||
|
||||
menuModule.getMenu = function () {
|
||||
return Menu.buildFromTemplate(mainMenu);
|
||||
};
|
||||
|
||||
|
@@ -1,48 +1,21 @@
|
||||
const { Tray, app } = require("electron");
|
||||
const { Menu } = require("electron");
|
||||
const { getMenu, mainMenu } = require("./menu");
|
||||
const { store, settings } = require("./settings");
|
||||
const { Tray } = require("electron");
|
||||
const { getMenu } = require("./menu");
|
||||
const trayModule = {};
|
||||
let tray;
|
||||
|
||||
trayModule.addTray = function (options = { icon: "" }) {
|
||||
trayModule.addTray = function (mainWindow, options = { icon: "" }) {
|
||||
tray = new Tray(options.icon);
|
||||
tray.setIgnoreDoubleClickEvents(true);
|
||||
tray.setToolTip("Tidal-hifi");
|
||||
|
||||
const menu = getMenu(mainWindow);
|
||||
|
||||
tray.setContextMenu(menu);
|
||||
};
|
||||
|
||||
trayModule.refreshTray = function (mainWindow) {
|
||||
if (!tray) {
|
||||
trayModule.addTray();
|
||||
}
|
||||
|
||||
tray.on("click", function (e) {
|
||||
if (mainWindow) {
|
||||
mainWindow.show();
|
||||
}
|
||||
});
|
||||
|
||||
tray.setToolTip("Tidal-hifi");
|
||||
|
||||
if (mainWindow && store.get(settings.minimizeOnClose)) {
|
||||
tray.setContextMenu(
|
||||
Menu.buildFromTemplate([
|
||||
{
|
||||
label: "Toggle Window",
|
||||
click: function () {
|
||||
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Quit",
|
||||
click: function () {
|
||||
mainWindow.destroy();
|
||||
app.quit();
|
||||
},
|
||||
},
|
||||
...mainMenu, //we add menu items from the other context
|
||||
])
|
||||
);
|
||||
} else {
|
||||
tray.setContextMenu(getMenu());
|
||||
trayModule.addTray(mainWindow);
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user