2022-07-01 20:17:40 +01:00
|
|
|
/*
|
2024-09-06 17:56:18 +01:00
|
|
|
Copyright 2022-2024 New Vector Ltd.
|
2022-07-01 20:17:40 +01:00
|
|
|
|
2024-09-06 17:56:18 +01:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-07-01 20:17:40 +01:00
|
|
|
*/
|
|
|
|
|
2024-10-30 18:06:03 +00:00
|
|
|
import * as tray from "./tray.js";
|
2022-07-01 20:17:40 +01:00
|
|
|
|
|
|
|
interface Setting {
|
|
|
|
read(): Promise<any>;
|
|
|
|
write(value: any): Promise<void>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Settings: Record<string, Setting> = {
|
|
|
|
"Electron.autoLaunch": {
|
|
|
|
async read(): Promise<any> {
|
|
|
|
return global.launcher.isEnabled();
|
|
|
|
},
|
|
|
|
async write(value: any): Promise<void> {
|
|
|
|
if (value) {
|
|
|
|
return global.launcher.enable();
|
|
|
|
} else {
|
|
|
|
return global.launcher.disable();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"Electron.warnBeforeExit": {
|
|
|
|
async read(): Promise<any> {
|
|
|
|
return global.store.get("warnBeforeExit", true);
|
|
|
|
},
|
|
|
|
async write(value: any): Promise<void> {
|
|
|
|
global.store.set("warnBeforeExit", value);
|
|
|
|
},
|
|
|
|
},
|
2022-12-15 11:00:58 +00:00
|
|
|
"Electron.alwaysShowMenuBar": {
|
|
|
|
// not supported on macOS
|
2022-07-01 20:17:40 +01:00
|
|
|
async read(): Promise<any> {
|
2022-11-30 13:51:54 +00:00
|
|
|
return !global.mainWindow!.autoHideMenuBar;
|
2022-07-01 20:17:40 +01:00
|
|
|
},
|
|
|
|
async write(value: any): Promise<void> {
|
2022-12-15 11:00:58 +00:00
|
|
|
global.store.set("autoHideMenuBar", !value);
|
2022-11-30 13:51:54 +00:00
|
|
|
global.mainWindow!.autoHideMenuBar = !value;
|
|
|
|
global.mainWindow!.setMenuBarVisibility(value);
|
2022-07-01 20:17:40 +01:00
|
|
|
},
|
|
|
|
},
|
2022-12-15 11:00:58 +00:00
|
|
|
"Electron.showTrayIcon": {
|
|
|
|
// not supported on macOS
|
2022-07-01 20:17:40 +01:00
|
|
|
async read(): Promise<any> {
|
|
|
|
return tray.hasTray();
|
|
|
|
},
|
|
|
|
async write(value: any): Promise<void> {
|
|
|
|
if (value) {
|
|
|
|
// Create trayIcon icon
|
|
|
|
tray.create(global.trayConfig);
|
|
|
|
} else {
|
|
|
|
tray.destroy();
|
|
|
|
}
|
2022-12-15 11:00:58 +00:00
|
|
|
global.store.set("minimizeToTray", value);
|
2022-07-01 20:17:40 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"Electron.enableHardwareAcceleration": {
|
|
|
|
async read(): Promise<any> {
|
2022-12-15 11:00:58 +00:00
|
|
|
return !global.store.get("disableHardwareAcceleration", false);
|
2022-07-01 20:17:40 +01:00
|
|
|
},
|
|
|
|
async write(value: any): Promise<void> {
|
2022-12-15 11:00:58 +00:00
|
|
|
global.store.set("disableHardwareAcceleration", !value);
|
2022-07-01 20:17:40 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|