From 2756d7a699056c9584b0e32175308d94e013bcb1 Mon Sep 17 00:00:00 2001 From: Nicholas Silva Date: Thu, 3 Oct 2024 22:10:30 -0400 Subject: [PATCH] titlebar changes --- src/preferences.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/preferences.js b/src/preferences.js index 7aeb1a276..40620916b 100644 --- a/src/preferences.js +++ b/src/preferences.js @@ -2,11 +2,40 @@ import { applyTheme } from '../renderer/themes.js'; import { translatePage } from '../renderer/i18n-translator.js'; - +import { nativeTheme } from 'electron'; // Import nativeTheme from Electron // Global values for preferences page let usersStyles; let preferences; +function applySystemTheme() { + // Check system preference for dark mode and set the theme accordingly + const systemTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light'; + preferences['theme'] = systemTheme; + applyTheme(systemTheme); +} + +function renderPreferencesWindow() { + const theme = 'theme'; + + // Apply system theme initially + applySystemTheme(); + + // Set theme dropdown to selected theme from usersStyles or system preferences + if (theme in usersStyles) { + $('#' + theme).val(usersStyles[theme]); + } + + $('#theme').on('change', function() { + changeValue('theme', this.value); + applyTheme(this.value); + }); + + // Continue with other preference setups... +} + +// Listen for theme changes in real-time +nativeTheme.on('updated', applySystemTheme); + function populateLanguages() { const languageOpts = $('#language');