From 720dcf65f1e30c3469c89899326256630716d09d Mon Sep 17 00:00:00 2001 From: Mike Knowles Date: Thu, 1 Oct 2020 23:22:28 -0700 Subject: [PATCH 1/2] Add option to minimize to tray --- js/main-window.js | 12 ++++++++---- js/user-preferences.js | 2 ++ src/preferences.html | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/js/main-window.js b/js/main-window.js index fca1b93f3..4dafdc3e3 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -98,10 +98,14 @@ function createWindow() tray.popUpContextMenu(contextMenu); }); - mainWindow.on('minimize', () => + mainWindow.on('minimize', (event) => { - event.preventDefault(); - mainWindow.hide(); + let savedPreferences = getUserPreferences(); + if (savedPreferences['minimize-to-tray']) + { + event.preventDefault(); + mainWindow.hide(); + } }); // Emitted when the window is closed. @@ -124,4 +128,4 @@ function createWindow() module.exports = { createWindow -}; \ No newline at end of file +}; diff --git a/js/user-preferences.js b/js/user-preferences.js index 9a0fde3d7..7cc8dce7f 100644 --- a/js/user-preferences.js +++ b/js/user-preferences.js @@ -9,6 +9,7 @@ const { isValidTheme } = require('./themes.js'); const defaultPreferences = { 'count-today': false, 'close-to-tray': true, + 'minimize-to-tray': true, 'hide-non-working-days': false, 'hours-per-day': '08:00', 'notification': true, @@ -114,6 +115,7 @@ function initPreferencesFileIfNotExistsOrInvalid() { // Handle Boolean Inputs case 'count-today': case 'close-to-tray': + case 'minimize-to-tray': case 'hide-non-working-days': case 'notification': case 'repetition': diff --git a/src/preferences.html b/src/preferences.html index f8cb4082b..ca132394b 100644 --- a/src/preferences.html +++ b/src/preferences.html @@ -74,6 +74,10 @@

Overall Balance Start Date

+
+

Minimize button should minimize to tray

+ +

Close button should minimize to tray

From 00695d0cf7e5ab8c0d69b8eeeaaa4df3814f3a31 Mon Sep 17 00:00:00 2001 From: Mike Knowles Date: Sat, 3 Oct 2020 20:28:01 -0700 Subject: [PATCH 2/2] Change let to const and resolve conflict --- js/main-window.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/main-window.js b/js/main-window.js index 5e990693f..1fd0f03ae 100644 --- a/js/main-window.js +++ b/js/main-window.js @@ -108,7 +108,7 @@ function createWindow() mainWindow.on('minimize', (event) => { - let savedPreferences = getUserPreferences(); + const savedPreferences = getUserPreferences(); if (savedPreferences['minimize-to-tray']) { event.preventDefault(); @@ -119,7 +119,7 @@ function createWindow() // Emitted when the window is closed. mainWindow.on('close', (event) => { - let savedPreferences = getUserPreferences(); + const savedPreferences = getUserPreferences(); if (!app.isQuitting && savedPreferences['close-to-tray']) { event.preventDefault();