diff --git a/CHANGELOG.md b/CHANGELOG.md index 24bca00b..a2a1bbfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added - Bengali, Catalan, Greek and Serbian translations +- it is not possible to close app during break that is in strict mode ### Fixed - error when end break shortcut is not set @@ -16,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - improved break window loading - updated many translations - better icons for "Show time in tray" +- `showBreakActionsInStrictMode` migrated to `showTrayMenuInStrictMode` ## [1.16.0] - 2024-08-11 ### Added diff --git a/README.md b/README.md index 0538ed63..9b68b118 100644 --- a/README.md +++ b/README.md @@ -370,8 +370,8 @@ To hide Stretchly icon in menubar/tray, set the value of `showTrayIcon` from `tr Note that this will disable graphical way of opening Stretchly Preferences. To access Preferences, you will have to use command line options (ie: `stretchly preferences` on Linux). -#### Show break actions (Skip, Pause, Reset) in Strict Mode -If you want to show options 'Skip to next break', 'Pause' or 'Reset Breaks' even while in Strict mode, set `showBreakActionsInStrictMode` to `true`. +#### Show tray menu in Strict Mode +If you want to show tray menu even while in Strict mode, set `showTrayMenuInStrictMode` to `true`. ## Contributor Preferences diff --git a/app/main.js b/app/main.js index 5ac4c41c..5977515c 100644 --- a/app/main.js +++ b/app/main.js @@ -57,7 +57,6 @@ let myStretchlyWindow = null let settings let pausedForSuspendOrLock = false let nextIdea = null -let appIsQuitting = false let updateChecker let currentTrayIconPath = null let currentTrayMenuTemplate = null @@ -161,9 +160,16 @@ app.on('ready', initialize) app.on('window-all-closed', () => { // do nothing, so app wont get closed }) -app.on('before-quit', () => { - appIsQuitting = true - globalShortcut.unregisterAll() +app.on('before-quit', (event) => { + if ((breakPlanner.scheduler.reference === 'finishMicrobreak' && settings.get('microbreakStrictMode')) || + (breakPlanner.scheduler.reference === 'finishBreak' && settings.get('breakStrictMode')) + ) { + log.info('Stretchly: preventing app closure (in break with strict mode)') + event.preventDefault() + } else { + globalShortcut.unregisterAll() + app.quit() + } }) async function initialize (isAppStart = true) { @@ -181,7 +187,7 @@ async function initialize (isAppStart = true) { }, migrations: { '1.13.0': store => { - if (store.get('pauseBreaksShortcut')) { + if (store.has('pauseBreaksShortcut')) { store.set('pauseBreaksToggleShortcut', store.get('pauseBreaksShortcut')) log.info(`Stretchly: settings pauseBreaksToggleShortcut to "${store.get('pauseBreaksShortcut')}"`) store.delete('pauseBreaksShortcut') @@ -189,10 +195,20 @@ async function initialize (isAppStart = true) { } else { log.info('Stretchly: not migrating pauseBreaksShortcut') } - if (store.get('pauseBreaksShortcut')) { + if (store.has('pauseBreaksShortcut')) { store.delete('resumeBreaksShortcut') log.info('Stretchly: removing resumeBreaksShortcut') } + }, + '1.17.0': store => { + if (store.has('showBreakActionsInStrictMode')) { + store.set('showTrayMenuInStrictMode', store.get('showBreakActionsInStrictMode')) + log.info(`Stretchly: settings showTrayMenuInStrictMode to "${store.get('showBreakActionsInStrictMode')}"`) + store.delete('showBreakActionsInStrictMode') + log.info('Stretchly: removing showBreakActionsInStrictMode') + } else { + log.info('Stretchly: not migrating showBreakActionsInStrictMode') + } } }, watch: true @@ -774,10 +790,10 @@ function startMicrobreak () { microbreakWinLocal.setAlwaysOnTop(!showBreaksAsRegularWindows, 'pop-up-menu') if (microbreakWinLocal) { microbreakWinLocal.on('close', (e) => { - if (settings.get('showBreaksAsRegularWindows')) { - if (!appIsQuitting && !microbreakWinLocal.fullScreen) { - e.preventDefault() - } + if (settings.get('microbreakStrictMode')) { + // not doing anything + log.info('Stretchly: preventing closing break window as in strict mode') + e.preventDefault() } }) microbreakWinLocal.on('closed', () => { @@ -922,10 +938,10 @@ function startBreak () { breakWinLocal.setAlwaysOnTop(!showBreaksAsRegularWindows, 'pop-up-menu') if (breakWinLocal) { breakWinLocal.on('close', (e) => { - if (settings.get('showBreaksAsRegularWindows')) { - if (!appIsQuitting && !breakWinLocal.fullScreen) { - e.preventDefault() - } + if (settings.get('breakStrictMode')) { + // not doing anything + log.info('Stretchly: preventing closing break window as in strict mode') + e.preventDefault() } }) breakWinLocal.on('closed', () => { @@ -1214,13 +1230,16 @@ function getTrayMenuTemplate () { }) } - if (breakPlanner.scheduler.reference === 'finishMicrobreak' && settings.get('microbreakStrictMode') && - !settings.get('showBreakActionsInStrictMode')) { - // nothing - } else if (breakPlanner.scheduler.reference === 'finishBreak' && settings.get('breakStrictMode') && - !settings.get('showBreakActionsInStrictMode')) { - // nothing - } else if (!(breakPlanner.isPaused || breakPlanner.dndManager.isOnDnd || breakPlanner.appExclusionsManager.isSchedulerCleared)) { + if ((breakPlanner.scheduler.reference === 'finishMicrobreak' && settings.get('microbreakStrictMode') && + !settings.get('showTrayMenuInStrictMode')) || + (breakPlanner.scheduler.reference === 'finishBreak' && settings.get('breakStrictMode') && + !settings.get('showTrayMenuInStrictMode')) + ) { + // empty menu, we are in strict mode + return trayMenu + } + + if (!(breakPlanner.isPaused || breakPlanner.dndManager.isOnDnd || breakPlanner.appExclusionsManager.isSchedulerCleared)) { let submenu = [] if (settings.get('microbreak')) { submenu = submenu.concat([{ @@ -1250,12 +1269,6 @@ function getTrayMenuTemplate () { updateTray() } }) - } else if (breakPlanner.scheduler.reference === 'finishMicrobreak' && settings.get('microbreakStrictMode') && - !settings.get('showBreakActionsInStrictMode')) { - // nothing - } else if (breakPlanner.scheduler.reference === 'finishBreak' && settings.get('breakStrictMode') && - !settings.get('showBreakActionsInStrictMode')) { - // nothing } else if (!(breakPlanner.dndManager.isOnDnd || breakPlanner.appExclusionsManager.isSchedulerCleared)) { trayMenu.push({ label: i18next.t('main.pause'), diff --git a/app/utils/defaultSettings.js b/app/utils/defaultSettings.js index d69bd02c..a0f1f8df 100644 --- a/app/utils/defaultSettings.js +++ b/app/utils/defaultSettings.js @@ -73,5 +73,5 @@ module.exports = { skipToNextMiniBreakShortcut: '', skipToNextLongBreakShortcut: '', resetBreaksShortcut: '', - showBreakActionsInStrictMode: false + showTrayMenuInStrictMode: false }