mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 23:44:59 +01:00
Merge pull request #1934 from element-hq/revert-1804-trayicons
Revert "Add monochrome tray icon"
This commit is contained in:
commit
4405f5dcf4
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB |
5
src/@types/global.d.ts
vendored
5
src/@types/global.d.ts
vendored
@ -20,8 +20,8 @@ declare global {
|
|||||||
var launcher: AutoLaunch;
|
var launcher: AutoLaunch;
|
||||||
var vectorConfig: Record<string, any>;
|
var vectorConfig: Record<string, any>;
|
||||||
var trayConfig: {
|
var trayConfig: {
|
||||||
color_icon_path: string; // eslint-disable-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
monochrome_icon_path: string; // eslint-disable-line camelcase
|
icon_path: string;
|
||||||
brand: string;
|
brand: string;
|
||||||
};
|
};
|
||||||
var store: Store<{
|
var store: Store<{
|
||||||
@ -31,7 +31,6 @@ declare global {
|
|||||||
autoHideMenuBar?: boolean;
|
autoHideMenuBar?: boolean;
|
||||||
locale?: string | string[];
|
locale?: string | string[];
|
||||||
disableHardwareAcceleration?: boolean;
|
disableHardwareAcceleration?: boolean;
|
||||||
monochromeIcon?: boolean;
|
|
||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
/* eslint-enable no-var */
|
/* eslint-enable no-var */
|
||||||
|
@ -212,11 +212,9 @@ async function setupGlobals(): Promise<void> {
|
|||||||
|
|
||||||
// The tray icon
|
// The tray icon
|
||||||
// It's important to call `path.join` so we don't end up with the packaged asar in the final path.
|
// It's important to call `path.join` so we don't end up with the packaged asar in the final path.
|
||||||
const colorIconFile = `element.${process.platform === "win32" ? "ico" : "png"}`;
|
const iconFile = `element.${process.platform === "win32" ? "ico" : "png"}`;
|
||||||
const monochromeIconFile = `monochrome.${process.platform === "win32" ? "ico" : "png"}`;
|
|
||||||
global.trayConfig = {
|
global.trayConfig = {
|
||||||
monochrome_icon_path: path.join(resPath, "img", monochromeIconFile),
|
icon_path: path.join(resPath, "img", iconFile),
|
||||||
color_icon_path: path.join(resPath, "img", colorIconFile),
|
|
||||||
brand: global.vectorConfig.brand || "Element",
|
brand: global.vectorConfig.brand || "Element",
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -455,7 +453,7 @@ app.on("ready", async () => {
|
|||||||
titleBarStyle: process.platform === "darwin" ? "hidden" : "default",
|
titleBarStyle: process.platform === "darwin" ? "hidden" : "default",
|
||||||
trafficLightPosition: { x: 9, y: 8 },
|
trafficLightPosition: { x: 9, y: 8 },
|
||||||
|
|
||||||
icon: global.trayConfig.color_icon_path,
|
icon: global.trayConfig.icon_path,
|
||||||
show: false,
|
show: false,
|
||||||
autoHideMenuBar: global.store.get("autoHideMenuBar", true),
|
autoHideMenuBar: global.store.get("autoHideMenuBar", true),
|
||||||
|
|
||||||
|
@ -67,13 +67,4 @@ export const Settings: Record<string, Setting> = {
|
|||||||
global.store.set("disableHardwareAcceleration", !value);
|
global.store.set("disableHardwareAcceleration", !value);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"Electron.monochromeIcon": {
|
|
||||||
async read(): Promise<any> {
|
|
||||||
return tray.isMonochrome();
|
|
||||||
},
|
|
||||||
async write(value: any): Promise<void> {
|
|
||||||
global.store.set("monochromeIcon", value);
|
|
||||||
tray.refreshIcon();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
20
src/tray.ts
20
src/tray.ts
@ -28,19 +28,6 @@ export function destroy(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isMonochrome(): boolean {
|
|
||||||
return global.store.get("monochromeIcon", process.platform === "linux");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function refreshIcon(): void {
|
|
||||||
const monochrome = isMonochrome();
|
|
||||||
if (monochrome) {
|
|
||||||
trayIcon?.setImage(nativeImage.createFromPath(global.trayConfig.monochrome_icon_path));
|
|
||||||
} else {
|
|
||||||
trayIcon?.setImage(nativeImage.createFromPath(global.trayConfig.color_icon_path));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleWin(): void {
|
function toggleWin(): void {
|
||||||
if (global.mainWindow?.isVisible() && !global.mainWindow.isMinimized() && global.mainWindow.isFocused()) {
|
if (global.mainWindow?.isVisible() && !global.mainWindow.isMinimized() && global.mainWindow.isFocused()) {
|
||||||
global.mainWindow.hide();
|
global.mainWindow.hide();
|
||||||
@ -52,8 +39,7 @@ function toggleWin(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IConfig {
|
interface IConfig {
|
||||||
color_icon_path: string; // eslint-disable-line camelcase
|
icon_path: string; // eslint-disable-line camelcase
|
||||||
monochrome_icon_path: string; // eslint-disable-line camelcase
|
|
||||||
brand: string;
|
brand: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,9 +52,7 @@ function getUuid(): string {
|
|||||||
export function create(config: IConfig): void {
|
export function create(config: IConfig): void {
|
||||||
// no trays on darwin
|
// no trays on darwin
|
||||||
if (process.platform === "darwin" || trayIcon) return;
|
if (process.platform === "darwin" || trayIcon) return;
|
||||||
const defaultIcon = nativeImage.createFromPath(
|
const defaultIcon = nativeImage.createFromPath(config.icon_path);
|
||||||
isMonochrome() ? config.monochrome_icon_path : config.color_icon_path,
|
|
||||||
);
|
|
||||||
|
|
||||||
let guid: string | undefined;
|
let guid: string | undefined;
|
||||||
if (process.platform === "win32" && app.isPackaged) {
|
if (process.platform === "win32" && app.isPackaged) {
|
||||||
|
Loading…
Reference in New Issue
Block a user