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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment.

// 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';
Comment on lines +17 to +18
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a function renderPreferencesWindow() below. It should be merged.


// 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...
Comment on lines +32 to +33
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

}

// Listen for theme changes in real-time
nativeTheme.on('updated', applySystemTheme);

Comment on lines +35 to +38
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be within the end of this file, on $(() => { ...?

function populateLanguages()
{
const languageOpts = $('#language');
Expand Down