feat: set background material on select menu change (remove restart requirement)

feat: set background material on select menu change (remove restart r…
This commit is contained in:
Xyloflake 2025-01-15 04:51:11 +05:30 committed by GitHub
commit 4b4de7ea45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 2 deletions

View file

@ -50,6 +50,7 @@ export default {
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS), get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
set: (settings: Settings, pathToNotify?: string) => invoke<void>(IpcEvents.SET_SETTINGS, settings, pathToNotify), set: (settings: Settings, pathToNotify?: string) => invoke<void>(IpcEvents.SET_SETTINGS, settings, pathToNotify),
getSettingsDir: () => invoke<string>(IpcEvents.GET_SETTINGS_DIR), getSettingsDir: () => invoke<string>(IpcEvents.GET_SETTINGS_DIR),
setBackgroundMaterial: (backgroundMaterial: Settings["winBackgroundMaterial"]) => invoke<void>(IpcEvents.SET_BACKGROUND_MATERIAL, backgroundMaterial)
}, },
quickCss: { quickCss: {

View file

@ -246,7 +246,7 @@ function VencordSettings() {
</>} </>}
{needsBackgroundMaterial && <> {needsBackgroundMaterial && <>
<Forms.FormTitle tag="h5">Window Background Material (requires restart)</Forms.FormTitle> <Forms.FormTitle tag="h5">Window Background Material</Forms.FormTitle>
<Select <Select
className={Margins.bottom20} className={Margins.bottom20}
placeholder="Window Background Material" placeholder="Window Background Material"
@ -277,7 +277,13 @@ function VencordSettings() {
value: "acrylic" value: "acrylic"
}, },
]} ]}
select={v => settings.winBackgroundMaterial = v} select={
v => {
settings.winBackgroundMaterial = v;
// IPC call to set background material in real time
VencordNative.settings.setBackgroundMaterial(v);
}
}
isSelected={v => settings.winBackgroundMaterial === v} isSelected={v => settings.winBackgroundMaterial === v}
serialize={identity} /> serialize={identity} />
</>} </>}

View file

@ -99,6 +99,11 @@ ipcMain.handle(IpcEvents.GET_THEME_SYSTEM_VALUES, () => ({
export function initIpc(mainWindow: BrowserWindow) { export function initIpc(mainWindow: BrowserWindow) {
// we need this handler in scope of mainWindow so we can call setBackgroundMaterial
ipcMain.handle(IpcEvents.SET_BACKGROUND_MATERIAL, (_, backgroundMaterial) => {
mainWindow.setBackgroundMaterial(backgroundMaterial);
});
let quickCssWatcher: FSWatcher | undefined; let quickCssWatcher: FSWatcher | undefined;
open(QUICKCSS_PATH, "a+").then(fd => { open(QUICKCSS_PATH, "a+").then(fd => {

View file

@ -30,6 +30,7 @@ export const enum IpcEvents {
GET_SETTINGS_DIR = "VencordGetSettingsDir", GET_SETTINGS_DIR = "VencordGetSettingsDir",
GET_SETTINGS = "VencordGetSettings", GET_SETTINGS = "VencordGetSettings",
SET_SETTINGS = "VencordSetSettings", SET_SETTINGS = "VencordSetSettings",
SET_BACKGROUND_MATERIAL = "setBackgroundMaterial",
OPEN_EXTERNAL = "VencordOpenExternal", OPEN_EXTERNAL = "VencordOpenExternal",
OPEN_QUICKCSS = "VencordOpenQuickCss", OPEN_QUICKCSS = "VencordOpenQuickCss",
GET_UPDATES = "VencordGetUpdates", GET_UPDATES = "VencordGetUpdates",