Skip to content

Commit

Permalink
Merge branch 'minimize-to-tray' of https://github.com/michaelknowles/…
Browse files Browse the repository at this point in the history
…time-to-leave into michaelknowles-minimize-to-tray
  • Loading branch information
thamara committed Oct 4, 2020
2 parents bd5fb9a + 00695d0 commit 819bbe8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions js/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,20 @@ function createWindow()
tray.popUpContextMenu(contextMenu);
});

mainWindow.on('minimize', () =>
mainWindow.on('minimize', (event) =>
{
event.preventDefault();
mainWindow.hide();
const savedPreferences = getUserPreferences();
if (savedPreferences['minimize-to-tray'])
{
event.preventDefault();
mainWindow.hide();
}
});

// 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();
Expand All @@ -133,4 +137,4 @@ function createWindow()
module.exports = {
createWindow,
getMainWindow
};
};
2 changes: 2 additions & 0 deletions js/user-preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -33,6 +34,7 @@ const defaultPreferences = {
const booleanInputs = [
'count-today',
'close-to-tray',
'minimize-to-tray',
'hide-non-working-days',
'notification',
'repetition',
Expand Down
4 changes: 4 additions & 0 deletions src/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<p>Overall Balance Start Date</p>
<label id='overall-balance-start-date'><input type="date" name="overall-balance-start-date"></label>
</div>
<div class="flex-box">
<p>Minimize button should minimize to tray</p>
<label id='minimize-to-tray' class="switch"><input type="checkbox" name="minimize-to-tray"><span class="slider round"></span></label>
</div>
<div class="flex-box">
<p>Close button should minimize to tray</p>
<label id='close-to-tray' class="switch"><input type="checkbox" name="close-to-tray"><span class="slider round"></span></label>
Expand Down

0 comments on commit 819bbe8

Please sign in to comment.