From 9b67fe0c60813d0436492c55a8c587b6c1bf1901 Mon Sep 17 00:00:00 2001 From: Andrey Onishchenko Date: Fri, 9 Feb 2024 23:13:29 +0300 Subject: [PATCH] App tray icon --- patches/0001-Add-package-licence.patch | 2 -- patches/0002-Add-package-icon.patch | 2 -- patches/0003-Create-app-tray-icon.patch | 43 +++++++++++++++++++++++++ patches/0003-Optional-fix-quit.patch | 15 --------- 4 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 patches/0003-Create-app-tray-icon.patch delete mode 100644 patches/0003-Optional-fix-quit.patch diff --git a/patches/0001-Add-package-licence.patch b/patches/0001-Add-package-licence.patch index e57352e..3adcf30 100644 --- a/patches/0001-Add-package-licence.patch +++ b/patches/0001-Add-package-licence.patch @@ -11,5 +11,3 @@ index 5844bdb..c1bab0e 100644 + "license": "UNLICENSED" } -- -2.42.0 - diff --git a/patches/0002-Add-package-icon.patch b/patches/0002-Add-package-icon.patch index 1d30795..880c4ad 100644 --- a/patches/0002-Add-package-icon.patch +++ b/patches/0002-Add-package-icon.patch @@ -14,5 +14,3 @@ index c1bab0e..d66268b 100644 + } } -- -2.42.0 - diff --git a/patches/0003-Create-app-tray-icon.patch b/patches/0003-Create-app-tray-icon.patch new file mode 100644 index 0000000..c385a70 --- /dev/null +++ b/patches/0003-Create-app-tray-icon.patch @@ -0,0 +1,43 @@ +diff --git a/main/lib/createTray.js b/main/lib/createTray.js +index e69de29..c8b9f0d 100644 +--- a/main/lib/createTray.js ++++ b/main/lib/createTray.js +@@ -0,0 +1,17 @@ ++const { app, Menu, Tray } = require('electron') ++ ++function createTray(window) { ++ const tray = new Tray('build/next-desktop/favicon.png'); ++ const contextMenu = Menu.buildFromTemplate([ ++ {label: 'Quit YandexMusic', click: app.quit} ++ ]); ++ tray.setToolTip('This is my application.'); ++ tray.setContextMenu(contextMenu); ++ ++ tray.on('click', () => { ++ window.show(); ++ }); ++ tray.setIgnoreDoubleClickEvents(true); ++} ++ ++exports.createTray = createTray; + +diff --git a/main/index.js b/main/index.js +index 28710d3..a4b3f87 100644 +--- a/main/index.js ++++ b/main/index.js +@@ -23,6 +23,7 @@ const handleMetrikaRequests_js_1 = require("./lib/handlers/handleMetrikaRequests + const loadURL_js_1 = require("./lib/loadURL.js"); + const safeRedirects_js_1 = require("./lib/safeRedirects.js"); + const handleWindowSessionEvents_js_1 = require("./lib/handlers/handleWindowSessionEvents.js"); ++const {createTray} = require('./lib/createTray.js'); + (0, handleError_js_1.handleUncaughtException)(); + (0, singleInstance_js_1.checkForSingleInstance)(); + (0, handleDeeplink_js_1.handleDeeplinkOnApplicationStartup)(); +@@ -30,6 +31,7 @@ const handleWindowSessionEvents_js_1 = require("./lib/handlers/handleWindowSessi + await electron_1.app.whenReady(); + (0, menu_js_1.setupMenu)(); + const window = await (0, createWindow_js_1.createWindow)(); ++ createTray(window); + (0, safeRedirects_js_1.safeRedirects)(window); + (0, handleWindowLifecycleEvents_js_1.handleWindowLifecycleEvents)(window); + (0, handleWindowSessionEvents_js_1.handleWindowSessionEvents)(window); diff --git a/patches/0003-Optional-fix-quit.patch b/patches/0003-Optional-fix-quit.patch deleted file mode 100644 index 6163797..0000000 --- a/patches/0003-Optional-fix-quit.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/main/lib/handlers/handleWindowLifecycleEvents.js b/main/lib/handlers/handleWindowLifecycleEvents.js -index 269d1f6..ff744b4 100644 ---- a/main/lib/handlers/handleWindowLifecycleEvents.js -+++ b/main/lib/handlers/handleWindowLifecycleEvents.js -@@ -36,6 +36,7 @@ const handleWindowLifecycleEvents = (window) => { - checkAndUpdateApplicationData(window); - }); - window.on('close', (event) => { -+ electron_1.app.quit(); - if (!state_js_1.state.willQuit) { - event.preventDefault(); - if (window.isFullScreen()) { --- -2.42.0 -