diff --git a/app/ipcHandlers.js b/app/ipcHandlers.js index 36a6ade..f4a3f4c 100644 --- a/app/ipcHandlers.js +++ b/app/ipcHandlers.js @@ -3,7 +3,7 @@ const fs = require("fs"); const path = require("path"); const { logger, logDir } = require("../server/logger"); const { configFeatures, featuresPath } = require("../config"); -const { getThemes } = require("./themeManager"); +const { getThemes, reloadThemes } = require("./themeManager"); const config = require("../config"); const { validateDownloadPath, getDefaultDownloadPath } = require("./pathValidator"); @@ -57,7 +57,7 @@ function registerIpcHandlers(getMainWindow) { getMainWindow()?.setProgressBar(percent / 100); }); - // Contrôles fenêtre (custom top bar) + // TOPBAR ACTION ipcMain.on("window-minimize", () => getMainWindow()?.minimize()); ipcMain.on("window-maximize", () => { const win = getMainWindow(); @@ -66,7 +66,7 @@ function registerIpcHandlers(getMainWindow) { }); ipcMain.on("window-close", () => getMainWindow()?.close()); - // Actions custom + ipcMain.on("open-devtools", () => getMainWindow()?.webContents.openDevTools({ mode: "detach" }) ); @@ -79,9 +79,16 @@ function registerIpcHandlers(getMainWindow) { ); ipcMain.on("open-config", () => shell.openPath(configFolderPath)); + + + // THEME + ipcMain.handle("get-themes", () => getThemes()); + ipcMain.on("open-theme", () => shell.openPath(themeFolderPath)); - ipcMain.handle("get-themes", () => getThemes()); + ipcMain.handle("reload-themes", async () => { + return await reloadThemes(); + }); // Modification des features ipcMain.handle("set-feature", (event, { key, value }) => { diff --git a/app/themeManager.js b/app/themeManager.js index 51acd5a..9a997ee 100644 --- a/app/themeManager.js +++ b/app/themeManager.js @@ -178,4 +178,11 @@ function getThemes() { return cachedThemes ?? []; } -module.exports = { initThemes, getThemes }; \ No newline at end of file +async function reloadThemes() { + const themes = await loadThemesFromFolder(); + cachedThemes = themes.sort((a, b) => getThemeOrder(a.id) - getThemeOrder(b.id)); + logger.info(`Themes reloaded: ${cachedThemes.length} theme(s)`); + return cachedThemes; +} + +module.exports = { initThemes, getThemes , reloadThemes }; \ No newline at end of file diff --git a/preload.js b/preload.js index a623352..3f7e4fa 100644 --- a/preload.js +++ b/preload.js @@ -9,6 +9,7 @@ contextBridge.exposeInMainWorld("electronAPI", { getVersion: () => ipcRenderer.invoke("version"), getValidatedDownloadPath: (path) => ipcRenderer.invoke("validate-download-path", path), getThemes: () => ipcRenderer.invoke("get-themes"), + reloadThemes: () => ipcRenderer.invoke("reload-themes") }); // Contrôles de fenêtre et outils custom pour la topbar diff --git a/public/index.html b/public/index.html index b2ababd..9581bb2 100644 --- a/public/index.html +++ b/public/index.html @@ -54,12 +54,18 @@