mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix conflicts after rebase
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
90e7677f36
commit
33cef4c9ef
26
src/main/tray/tray-icon-path.injectable.ts
Normal file
26
src/main/tray/tray-icon-path.injectable.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import getAbsolutePathInjectable from "../../common/path/get-absolute-path.injectable";
|
||||||
|
import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable";
|
||||||
|
import isDevelopmentInjectable from "../../common/vars/is-development.injectable";
|
||||||
|
|
||||||
|
const trayIconPathInjectable = getInjectable({
|
||||||
|
id: "tray-icon-path",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
|
||||||
|
const staticFilesDirectory = di.inject(staticFilesDirectoryInjectable);
|
||||||
|
const isDevelopment = di.inject(isDevelopmentInjectable);
|
||||||
|
|
||||||
|
return getAbsolutePath(
|
||||||
|
staticFilesDirectory,
|
||||||
|
isDevelopment ? "../build/tray" : "icons", // copied within electron-builder extras
|
||||||
|
"trayIconTemplate.png",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default trayIconPathInjectable;
|
||||||
@ -11,6 +11,7 @@ import { getStartableStoppable } from "../../common/utils/get-startable-stoppabl
|
|||||||
import isAutoUpdateEnabledInjectable from "../is-auto-update-enabled.injectable";
|
import isAutoUpdateEnabledInjectable from "../is-auto-update-enabled.injectable";
|
||||||
import showAboutInjectable from "../menu/show-about.injectable";
|
import showAboutInjectable from "../menu/show-about.injectable";
|
||||||
import showApplicationWindowInjectable from "../start-main-application/lens-window/show-application-window.injectable";
|
import showApplicationWindowInjectable from "../start-main-application/lens-window/show-application-window.injectable";
|
||||||
|
import trayIconPathInjectable from "./tray-icon-path.injectable";
|
||||||
|
|
||||||
const trayInjectable = getInjectable({
|
const trayInjectable = getInjectable({
|
||||||
id: "tray",
|
id: "tray",
|
||||||
@ -22,6 +23,7 @@ const trayInjectable = getInjectable({
|
|||||||
const isAutoUpdateEnabled = di.inject(isAutoUpdateEnabledInjectable);
|
const isAutoUpdateEnabled = di.inject(isAutoUpdateEnabledInjectable);
|
||||||
const showApplicationWindow = di.inject(showApplicationWindowInjectable);
|
const showApplicationWindow = di.inject(showApplicationWindowInjectable);
|
||||||
const showAboutPopup = di.inject(showAboutInjectable);
|
const showAboutPopup = di.inject(showAboutInjectable);
|
||||||
|
const trayIconPath = di.inject(trayIconPathInjectable);
|
||||||
|
|
||||||
return getStartableStoppable("build-of-tray", () =>
|
return getStartableStoppable("build-of-tray", () =>
|
||||||
initTray(
|
initTray(
|
||||||
@ -31,6 +33,7 @@ const trayInjectable = getInjectable({
|
|||||||
isAutoUpdateEnabled,
|
isAutoUpdateEnabled,
|
||||||
showApplicationWindow,
|
showApplicationWindow,
|
||||||
showAboutPopup,
|
showAboutPopup,
|
||||||
|
trayIconPath,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -9,25 +9,16 @@ import type { IComputedValue } from "mobx";
|
|||||||
import { autorun } from "mobx";
|
import { autorun } from "mobx";
|
||||||
import { checkForUpdates } from "../app-updater";
|
import { checkForUpdates } from "../app-updater";
|
||||||
import logger from "../logger";
|
import logger from "../logger";
|
||||||
import { isDevelopment, isWindows, productName, staticFilesDirectory } from "../../common/vars";
|
import { isWindows, productName } from "../../common/vars";
|
||||||
import type { Disposer } from "../../common/utils";
|
import type { Disposer } from "../../common/utils";
|
||||||
import { disposer, toJS } from "../../common/utils";
|
import { disposer, toJS } from "../../common/utils";
|
||||||
import type { TrayMenuRegistration } from "./tray-menu-registration";
|
import type { TrayMenuRegistration } from "./tray-menu-registration";
|
||||||
import path from "path";
|
|
||||||
|
|
||||||
const TRAY_LOG_PREFIX = "[TRAY]";
|
const TRAY_LOG_PREFIX = "[TRAY]";
|
||||||
|
|
||||||
// note: instance of Tray should be saved somewhere, otherwise it disappears
|
// note: instance of Tray should be saved somewhere, otherwise it disappears
|
||||||
export let tray: Tray;
|
export let tray: Tray;
|
||||||
|
|
||||||
function getTrayIconPath(): string {
|
|
||||||
return path.resolve(
|
|
||||||
staticFilesDirectory,
|
|
||||||
isDevelopment ? "../build/tray" : "icons", // copied within electron-builder extras
|
|
||||||
"trayIconTemplate.png",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initTray(
|
export function initTray(
|
||||||
trayMenuItems: IComputedValue<TrayMenuRegistration[]>,
|
trayMenuItems: IComputedValue<TrayMenuRegistration[]>,
|
||||||
navigateToPreferences: () => void,
|
navigateToPreferences: () => void,
|
||||||
@ -35,10 +26,9 @@ export function initTray(
|
|||||||
isAutoUpdateEnabled: () => boolean,
|
isAutoUpdateEnabled: () => boolean,
|
||||||
showApplicationWindow: () => Promise<void>,
|
showApplicationWindow: () => Promise<void>,
|
||||||
showAbout: () => void,
|
showAbout: () => void,
|
||||||
|
trayIconPath: string,
|
||||||
): Disposer {
|
): Disposer {
|
||||||
const icon = getTrayIconPath();
|
tray = new Tray(trayIconPath);
|
||||||
|
|
||||||
tray = new Tray(icon);
|
|
||||||
tray.setToolTip(packageInfo.description);
|
tray.setToolTip(packageInfo.description);
|
||||||
tray.setIgnoreDoubleClickEvents(true);
|
tray.setIgnoreDoubleClickEvents(true);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user