From ef503a1e29a540c7318efb5f2018efbf00706198 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Thu, 19 Oct 2017 11:15:25 +0200 Subject: Add option to disable system tray icon --- src/index.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index 3244c44ad..6f45d95b8 100644 --- a/src/index.js +++ b/src/index.js @@ -2,16 +2,18 @@ import { app, BrowserWindow, shell } from 'electron'; import fs from 'fs-extra'; import path from 'path'; -// eslint-disable-next-line +/* eslint-disable */ if (require('electron-squirrel-startup')) app.quit(); -import windowStateKeeper from 'electron-window-state'; // eslint-disable-line +import windowStateKeeper from 'electron-window-state'; -import { isDevMode, isWindows } from './environment'; // eslint-disable-line -import ipcApi from './electron/ipc-api'; // eslint-disable-line -import Settings from './electron/Settings'; // eslint-disable-line -import { appId } from './package.json'; // eslint-disable-line -import './electron/exception'; // eslint-disable-line +import { isDevMode, isWindows } from './environment'; +import ipcApi from './electron/ipc-api'; +import Tray from './lib/Tray'; +import Settings from './electron/Settings'; +import { appId } from './package.json'; +import './electron/exception'; +/* eslint-enable */ // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. @@ -47,8 +49,11 @@ const createWindow = async () => { autoHideMenuBar: true, }); + // Initialize System Tray + const trayIcon = new Tray(mainWindow); + // Initialize ipcApi - ipcApi({ mainWindow, settings }); + ipcApi({ mainWindow, settings, trayIcon }); // Manage Window State mainWindowState.manage(mainWindow); @@ -102,6 +107,10 @@ const createWindow = async () => { if (app.wasMaximized) { mainWindow.maximize(); } + + if (!settings.get('enableSystemTray')) { + trayIcon.hide(); + } }); mainWindow.on('show', () => { -- cgit v1.2.3-70-g09d2 From 9825e2aabceea0c1bc987abb6834051bfc99ba54 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Thu, 19 Oct 2017 15:23:02 +0200 Subject: Display system tray icon when minimizing to system tray --- src/index.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index 6f45d95b8..e7fa7da6d 100644 --- a/src/index.js +++ b/src/index.js @@ -90,6 +90,7 @@ const createWindow = async () => { if (settings.get('minimizeToSystemTray')) { mainWindow.setSkipTaskbar(true); + trayIcon.show(); } }); -- cgit v1.2.3-70-g09d2 From 2ae409e1f2622b509703ed814d3aa8f4e136d09a Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Mon, 23 Oct 2017 15:23:26 +0200 Subject: fix(App): Force Franz to use single window Fixes #29 --- src/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index e7fa7da6d..b07666ba2 100644 --- a/src/index.js +++ b/src/index.js @@ -18,7 +18,6 @@ import './electron/exception'; // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow; -const settings = new Settings(); let willQuitApp = false; // Ensure that the recipe directory exists @@ -29,6 +28,21 @@ if (isWindows) { app.setAppUserModelId(appId); } +// Force single window +const isSecondInstance = app.makeSingleInstance(() => { + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore(); + mainWindow.focus(); + } +}); + +if (isSecondInstance) { + app.quit(); +} + +// Initialize Settings +const settings = new Settings(); + const createWindow = async () => { // Remember window size const mainWindowState = windowStateKeeper({ -- cgit v1.2.3-70-g09d2 From 2bfe8456d62d1ca828fe10a00c1c436b164cd061 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Tue, 24 Oct 2017 22:30:15 +0200 Subject: Don't apply app.makeSingleInstance on macOS --- src/index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index b07666ba2..9ca059f48 100644 --- a/src/index.js +++ b/src/index.js @@ -29,15 +29,17 @@ if (isWindows) { } // Force single window -const isSecondInstance = app.makeSingleInstance(() => { - if (mainWindow) { - if (mainWindow.isMinimized()) mainWindow.restore(); - mainWindow.focus(); - } -}); +if (process.platform !== 'darwin') { + const isSecondInstance = app.makeSingleInstance(() => { + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore(); + mainWindow.focus(); + } + }); -if (isSecondInstance) { - app.quit(); + if (isSecondInstance) { + app.quit(); + } } // Initialize Settings -- cgit v1.2.3-70-g09d2