Skip to content

Commit

Permalink
Fixed right-click menu
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Nov 28, 2022
1 parent fa68814 commit 1c09b37
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/electron.js
Expand Up @@ -2350,12 +2350,10 @@ function createTray() {
function setTrayMenu() {
if (tray === null) return false;

let willShowPausableItems = (settings.detectIdleTimeEnabled || settings.adjustmentTimes.length ? true : false)

const contextMenu = Menu.buildFromTemplate([
getTimeAdjustmentsMenuItem(),
getDetectIdleMenuItem(),
{ type: 'separator', visible: (willShowPausableItems) },
getPausableSeparatorMenuItem(),
{ label: T.t("GENERIC_REFRESH_DISPLAYS"), type: 'normal', click: () => refreshMonitors(true, true) },
{ label: T.t("GENERIC_SETTINGS"), type: 'normal', click: createSettings },
{ type: 'separator' },
Expand All @@ -2365,6 +2363,13 @@ function setTrayMenu() {
tray.setContextMenu(contextMenu)
}

function getPausableSeparatorMenuItem() {
if(settings.detectIdleTimeEnabled || settings.adjustmentTimes.length > 0) {
return { type: 'separator' }
}
return { label: "", visible: false }
}

function getTimeAdjustmentsMenuItem() {
if(settings.adjustmentTimes?.length) {
return { label: T.t("GENERIC_PAUSE_TOD"), type: 'checkbox', click: (e) => tempSettings.pauseTimeAdjustments = e.checked }
Expand Down

0 comments on commit 1c09b37

Please sign in to comment.