TagSpaces is an offline, open source, document manager with tagging support
feat: adding dock menu for macos
Ilian Sapundshiev768f7babd251
diff --git a/src/main/electron-dock-menu.ts b/src/main/electron-dock-menu.tsnew file mode 100644index 000000000..01e21cbdb--- /dev/null+++ b/src/main/electron-dock-menu.ts@@ -0,0 +1,80 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2024-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import { app, Menu } from 'electron';++export default function buildDockMenu(mainPageProps: any, i18n) {+ function openNextFile() {+ mainPageProps.openNextFile();+ }++ function openPrevFile() {+ mainPageProps.openPrevFile();+ }++ function playResumePlayback() {+ mainPageProps.resumePlayback();+ }++ const dockMenuTemplate = [+ {+ label: i18n.t('newWindow'),+ click: () => mainPageProps.createNewWindowInstance(),+ },+ {+ type: 'separator',+ },+ {+ label: i18n.t('showTagSpaces'),+ click: mainPageProps.showTagSpaces,+ },+ {+ label: i18n.t('showSearch'),+ click: mainPageProps.openSearch,+ },+ {+ type: 'separator',+ },+ {+ label: i18n.t('newFileNote'),+ click: mainPageProps.toggleNewFileDialog,+ },+ {+ type: 'separator',+ },+ {+ label: i18n.t('openNextFileTooltip'),+ click: openNextFile,+ },+ {+ label: i18n.t('openPrevFileTooltip'),+ click: openPrevFile,+ },+ {+ type: 'separator',+ },+ {+ label: i18n.t('pauseResumePlayback'),+ click: playResumePlayback,+ },+ ];++ // @ts-ignore+ const dockMenu = Menu.buildFromTemplate(dockMenuTemplate);+ return dockMenu;+}diff --git a/src/main/electron-tray-menu.ts b/src/main/electron-tray-menu.tsindex 081cc63b7..050f7349c 100644--- a/src/main/electron-tray-menu.ts+++ b/src/main/electron-tray-menu.ts@@ -29,7 +29,7 @@ const icon2xBlack =const icon2xWhite ='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAACXBIWXMAAACjAAAAowHwx5rOAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAA+FJREFUWIW1mV2IVVUUx/93ZjLTCDM0sDIqKY2G7AMq+0ChlCh8GAkCwUj7xPKhD4ueBgp6KRA0iKSggsAHw/BxqCfJIEoxMjKRKCU11KwpR7vdXw9rTnPuae919pm75w+HuXPOXmv/zt5rr732vS1AU6B+SdskrcrlsC+Xo5JakrYqI6Q0NaBvSXo0t9PcoK9LejqzT0l5QTdKejmjvy61Mi2mJyS9LYvPkL6T9Feir0WSZvzvLtDrNQS0iet9oK+Bv69CTnqd+uWSPpKlo5B2SFonqVO615K0QNLtkmYm99TDSC4BRp2RHAHOr9jcAOwptRkDXkwZ0clCLgZOOZC7gQsrNrOAnyvtOuN/H5sK0GuBow7kPuDigN2TkfYd4Ps60KYxeoWkEUmXRp4flMXtqcCzhRGbImYHvI6bgM6VQc6PPD8s6T5JR0v3zit9PhCxQ9IhSW2398TpnkX3IqjqOLCoYtMPbAfeAwaA2cAvgWkHWF839SmQM4BdDuRvwM0Bu82lNjuAC4BbgP2l++eAYaDVK+h04FMH8k/gzoDdcKDtbuASbHRvBO7FRjkp4XuQA+MjEdNZYEXA7jbH5hvgMqfPO4jk5phBH/Ch02EbeMixfxb4J2J7BBgM2NyKhVFQsY42xwywBbDOsS2uIeBMxMdJ4K5S28XACafPQ6EOXnMMAF5IgCxmZRnxUToDrAKuw99AfgKuqjrfUAM5nAi5EfgEyxiDwOGIv7bzIoy/wEKgK48+wkReC2lLIuTDTMTnF8Ac4GrggOM7pGPA9YXfcjx5NeUHpNWUS7GKqKwfgGuw1PR5IuSvWKX1n28B92OpJqaPsVRVBzmbeEV1BMudM4HPaiBPYIury3+fpKckTXN22YskTXf3YdNJSWsljQWezZO0S9JKWWET02lJKyTtDe3104BtNW/5JRZrKTG61BlZbw2MAnfH/BYf+oF3amC/BS5PAJ2Dv9JjkPd4fsv/tAjv0WX9iBXOMYfrsWS+BJgH7E2AHMPWiTsAoZsb8KfoGHBTwG41E2lpFKsD5gO/O77OAg/UQcZABawB/nY6+AOrfor2D2IlWxViP3GdA1amQHqgGncS26vBpmwIy68pU1xWG9sYkiDrQIsVfLqmw7XAXODrBpCrm0CmgAorv447HXeA57HjsVdkF20fbwqZCipsz62eyat6FStEskM2ARVwJXb+now6dB/gphRUNIvFsp7rBXIyoMJicaQB5Cu9Qk4WVNjRd2cC5HAOyF5AhdUH7zqQb+aC7BVUWH3wRgByU07IHKDF9VIJcivd33xkuXJ9hy9Jz0galBXi2X9l+xc7opIKau8a2gAAAABJRU5ErkJggg==';-export default function buildTrayIconMenu(mainPageProps: any, i18n, isMacLike) {+export default function buildTrayMenu(mainPageProps: any, i18n, isMacLike) {// const cKey = isMacLike ? ' - ⌘' : ' - Ctrl';// const sKey = isMacLike ? '⇧' : 'Shift';// const pKey = isMacLike ? ' ' : ' + ';diff --git a/src/main/main.ts b/src/main/main.tsindex 5de61d1f5..eb415c6af 100644--- a/src/main/main.ts+++ b/src/main/main.ts@@ -27,7 +27,8 @@ import findFreePorts from 'find-free-ports';import settings from './settings';import { getExtensions } from './extension-utils';import i18nInit from '../renderer/services/i18nInit';-import buildTrayIconMenu from './electron-tray-menu';+import buildTrayMenu from './electron-tray-menu';+import buildDockMenu from './electron-dock-menu';import buildDesktopMenu from './electron-menus';import loadMainEvents from './mainEvents';import { Extensions } from './types';@@ -307,8 +308,8 @@ function createNewWindowInstance(url?) {}}-function buildTrayMenu(i18n) {- buildTrayIconMenu(+function bindTrayMenu(i18n) {+ buildTrayMenu({showTagSpaces: showApp,resumePlayback,@@ -324,7 +325,7 @@ function buildTrayMenu(i18n) {);}-function buildAppMenu(i18n) {+function bindAppMenu(i18n) {buildDesktopMenu({showTagSpaces: showApp,@@ -526,8 +527,8 @@ const createWindow = async (i18n) => {);try {- buildAppMenu(i18n);- buildTrayMenu(i18n);+ bindAppMenu(i18n);+ bindTrayMenu(i18n);} catch (ex) {console.log('buildMenus', ex);}@@ -591,6 +592,22 @@ app.then(() => {return i18nInit().then((i18n) => {appI18N = i18n;+ if (process.platform === 'darwin') {+ app.dock.setMenu(+ buildDockMenu(+ {+ showTagSpaces: showApp,+ resumePlayback,+ createNewWindowInstance,+ openSearch: showSearch,+ toggleNewFileDialog: newTextFile,+ openNextFile: getNextFile,+ openPrevFile: getPreviousFile,+ },+ i18n,+ ),+ );+ }createWindow(i18n);app.on('activate', () => {// On macOS it's common to re-create a window in the app when the@@ -601,7 +618,7 @@ appi18n.on('languageChanged', (lng) => {try {console.log('languageChanged:' + lng);- buildAppMenu(i18n);+ bindAppMenu(i18n);buildTrayMenu(i18n);const spellCheckLanguage = getSpellcheckLanguage(lng);mainWindow?.webContents.session.setSpellCheckerLanguages([