Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: use special icon for tray

Abdullah Atta7df64837fe20
diff --git a/apps/web/desktop/asset-manager.ts b/apps/web/desktop/asset-manager.ts
index a50be690b..3d049f81d 100644
--- a/apps/web/desktop/asset-manager.ts
+++ b/apps/web/desktop/asset-manager.ts
@@ -26,7 +26,7 @@ import { getSystemTheme } from "./config/theme";
type Formats = "ico" | "png" | "icns";
type IconOptions<TFormat extends Formats> = {
- size?: 16 | 24 | 32 | 48 | 64 | 128 | 256 | 512 | 1024;
+ size?: 16 | 22 | 24 | 32 | 48 | 64 | 128 | 256 | 512 | 1024;
format?: TFormat;
};
@@ -45,7 +45,13 @@ const RESOURCES_DIR = isDevelopment()
);
const prefixes = ["", ".dark"];
-const icons = ["note-add", "notebook-add", "reminder-add", "quit"] as const;
+const icons = [
+ "note-add",
+ "notebook-add",
+ "reminder-add",
+ "quit",
+ "tray-icon"
+] as const;
const ALL_ICONS: {
id: IconNames;
@@ -84,7 +90,7 @@ export class AssetManager {
static icon<TFormat extends Formats>(
name: IconNames,
options: IconOptions<TFormat>
- ): FlexibleIcon<TFormat> | undefined {
+ ): FlexibleIcon<TFormat> {
const { size = 16, format = "png" } = options;
const prefix: Prefixes = getSystemTheme() === "dark" ? ".dark" : "";
@@ -98,7 +104,10 @@ export class AssetManager {
if (format === "ico") return icoPath as FlexibleIcon<TFormat>;
const icon = ALL_ICONS.find((a) => a.id === name && a.prefix === prefix);
- if (!icon) return;
+ if (!icon)
+ return nativeImage.createFromPath(
+ AssetManager.appIcon(options)
+ ) as FlexibleIcon<TFormat>;
return nativeImage.createFromBuffer(
Buffer.from(
diff --git a/apps/web/desktop/assets/icons/tray-icon.dark.ico b/apps/web/desktop/assets/icons/tray-icon.dark.ico
new file mode 100644
index 000000000..3e23cdbd1
Binary files /dev/null and b/apps/web/desktop/assets/icons/tray-icon.dark.ico differ
diff --git a/apps/web/desktop/assets/icons/tray-icon.ico b/apps/web/desktop/assets/icons/tray-icon.ico
new file mode 100644
index 000000000..31170f2e5
Binary files /dev/null and b/apps/web/desktop/assets/icons/tray-icon.ico differ
diff --git a/apps/web/desktop/electron.js b/apps/web/desktop/electron.js
index 312e9c705..56a3dce3b 100644
--- a/apps/web/desktop/electron.js
+++ b/apps/web/desktop/electron.js
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import "isomorphic-fetch";
import { app, BrowserWindow, nativeTheme, shell } from "electron";
-import { APP_ICON_PATH, isDevelopment } from "./utils";
+import { isDevelopment } from "./utils";
import { registerProtocol, PROTOCOL_URL } from "./protocol";
import { configureAutoUpdater } from "./autoupdate";
import { getBackgroundColor, getTheme, setTheme } from "./config/theme";
@@ -69,15 +69,18 @@ async function createWindow() {
width: mainWindowState.width,
height: mainWindowState.height,
fullscreen: mainWindowState.isFullScreen,
-
+ darkTheme: getTheme() === "dark",
backgroundColor: getBackgroundColor(),
+
autoHideMenuBar: true,
- icon: APP_ICON_PATH,
+ icon: AssetManager.appIcon({
+ size: 512,
+ format: process.platform === "win32" ? "ico" : "png"
+ }),
webPreferences: {
zoomFactor: getZoomFactor(),
devTools: true, // isDev,
nodeIntegration: false, //true,
- enableRemoteModule: false,
contextIsolation: true,
nativeWindowOpen: true,
spellcheck: getIsSpellCheckerEnabled(),
@@ -85,7 +88,6 @@ async function createWindow() {
}
});
- mainWindow.setAutoHideMenuBar(true);
mainWindowState.manage(mainWindow);
globalThis.window = mainWindow;
setupMenu();
diff --git a/apps/web/desktop/tray.ts b/apps/web/desktop/tray.ts
index c1cf1b7a2..bec28fb29 100644
--- a/apps/web/desktop/tray.ts
+++ b/apps/web/desktop/tray.ts
@@ -27,12 +27,17 @@ let tray: Tray | undefined = undefined;
export function setupTray() {
if (tray) tray.destroy();
- tray = new Tray(AssetManager.appIcon({ size: process.platform === "darwin" ? 24 : 32 }));
+ tray = new Tray(
+ AssetManager.icon("tray-icon", {
+ size: process.platform === "darwin" ? 22 : 32
+ })
+ );
+
const contextMenu = Menu.buildFromTemplate([
{
label: "Show app",
type: "normal",
- icon: AssetManager.appIcon({ size: 16 }),
+ icon: AssetManager.icon("tray-icon", { size: 16 }),
click: bringToFront
},
{ type: "separator" },
@@ -65,7 +70,7 @@ export function setupTray() {
}
]);
tray.on("double-click", bringToFront);
- if (process.platform !== "darwin") tray.on("click", bringToFront);
+ if (process.platform !== "darwin") tray.on("click", bringToFront);
tray.setToolTip("Notesnook");
tray.setContextMenu(contextMenu);
}