Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

titlebar changes #1080

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down