Skip to content

Commit

Permalink
Add API - setWindowStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
webfiltered committed Dec 26, 2024
1 parent cb4b186 commit 791d741
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const IPC_CHANNELS = {
SHOW_CONTEXT_MENU: 'show-context-menu',
RESTART_CORE: 'restart-core',
GET_GPU: 'get-gpu',
SET_WINDOW_STYLE: 'set-window-style',
} as const;

export enum ProgressStatus {
Expand Down
7 changes: 7 additions & 0 deletions src/handlers/appInfoHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { app, ipcMain } from 'electron';
import { IPC_CHANNELS } from '../constants';
import { useDesktopConfig } from '../store/desktopConfig';
import type { TorchDeviceType } from '../preload';
import type { DesktopSettings } from '../store/desktopSettings';

/**
* Handles information about the app and current state in IPC channels.
Expand All @@ -20,5 +21,11 @@ export class AppInfoHandlers {
ipcMain.handle(IPC_CHANNELS.GET_GPU, async (): Promise<TorchDeviceType | undefined> => {
return await useDesktopConfig().getAsync('detectedGpu');
});
ipcMain.handle(
IPC_CHANNELS.SET_WINDOW_STYLE,
async (_event: Electron.IpcMainInvokeEvent, style: DesktopSettings['windowStyle']): Promise<void> => {
await useDesktopConfig().setAsync('windowStyle', style);
}
);
}
}
5 changes: 5 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { contextBridge, ipcRenderer } from 'electron';
import { IPC_CHANNELS, ELECTRON_BRIDGE_API, ProgressStatus, DownloadStatus } from './constants';
import type { DownloadState } from './models/DownloadManager';
import path from 'node:path';
import type { DesktopSettings } from './store/desktopSettings';

/**
* Open a folder in the system's default file explorer.
Expand Down Expand Up @@ -283,6 +284,10 @@ const electronAPI = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return await ipcRenderer.invoke(IPC_CHANNELS.GET_GPU);
},
/** Sets the window style */
setWindowStyle: (style: DesktopSettings['windowStyle']): Promise<void> => {
return ipcRenderer.invoke(IPC_CHANNELS.SET_WINDOW_STYLE, style);
},
},
/** Restart the python server without restarting desktop. */
restartCore: async (): Promise<void> => {
Expand Down

0 comments on commit 791d741

Please sign in to comment.