default theme on macOS

This commit is contained in:
antelle 2020-05-22 11:44:49 +02:00
parent c3b55cd7fa
commit e5073eb65f
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
5 changed files with 23 additions and 6 deletions

View File

@ -11,6 +11,7 @@ const extraThemes = Features.isMac || Features.isiOS ? appleThemes : {};
const SettingsManager = {
neutralLocale: null,
activeLocale: 'en',
activeTheme: null,
allLocales: {
'en': 'English',
@ -32,9 +33,7 @@ const SettingsManager = {
customLocales: {},
setBySettings(settings) {
if (settings.theme) {
this.setTheme(settings.theme);
}
this.setTheme(settings.theme);
this.setFontSize(settings.fontSize);
const locale = settings.locale;
try {
@ -46,7 +45,17 @@ const SettingsManager = {
} catch (ex) {}
},
getDefaultTheme() {
return Features.isMac ? 'macdark' : 'fb';
},
setTheme(theme) {
if (!theme) {
if (this.activeTheme) {
return;
}
theme = this.getDefaultTheme();
}
for (const cls of document.body.classList) {
if (/^th-/.test(cls)) {
document.body.classList.remove(cls);
@ -57,6 +66,7 @@ const SettingsManager = {
if (metaThemeColor) {
metaThemeColor.content = window.getComputedStyle(document.body).backgroundColor;
}
this.activeTheme = theme;
},
getThemeClass(theme) {

View File

@ -1,5 +1,5 @@
const DefaultAppSettings = {
theme: 'fb', // UI theme
theme: null, // UI theme
locale: null, // user interface language
expandGroups: true, // show entries from all subgroups
listViewWidth: null, // width of the entry list representation

View File

@ -71,7 +71,7 @@ class SettingsGeneralView extends View {
super.render({
themes: mapObject(SettingsManager.allThemes, theme => Locale[theme]),
activeTheme: AppSettingsModel.theme,
activeTheme: SettingsManager.activeTheme,
locales: SettingsManager.allLocales,
activeLocale: SettingsManager.activeLocale,
fontSize: AppSettingsModel.fontSize,

View File

@ -188,7 +188,13 @@ function setSystemAppearance() {
perfTimestamps?.push({ name: 'setting system appearance', ts: process.hrtime() });
}
function getDefaultTheme() {
return process.platform === 'darwin' ? 'macdark' : 'fb';
}
function createMainWindow() {
const theme = appSettings.theme || getDefaultTheme();
const bgColor = themeBgColors[theme] || defaultBgColor;
const windowOptions = {
show: false,
width: 1000,
@ -196,7 +202,7 @@ function createMainWindow() {
minWidth: 700,
minHeight: 400,
titleBarStyle: appSettings.titlebarStyle,
backgroundColor: themeBgColors[appSettings.theme] || defaultBgColor,
backgroundColor: bgColor,
webPreferences: {
backgroundThrottling: false,
nodeIntegration: true,

View File

@ -6,6 +6,7 @@ Release notes
`+` #1503: ARM64 Windows support
`+` #1480: option to create a portable installation
`+` #1400: auto-apply tag when creating new entry in tag view
`*` default theme on macOS is now macOS-Dark
`+` #1342: hint that the data will be stored in unencrypted form after exporting
`*` #1471: WebDAV url validation, only HTTPS is allowed
`+` #1350: clearing master password after auto lock period