1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Desktop: Resolves #2665: Add support for system theme auto-switching

This commit is contained in:
Laurent Cozic
2020-05-21 00:47:38 +01:00
parent 3830f36c0b
commit 49451dba20
3 changed files with 93 additions and 16 deletions

View File

@ -37,6 +37,21 @@ class Setting extends BaseModel {
// if if private a setting might still be handled and modified by the app. For instance, the settings related to sorting notes are not
// public for the mobile and desktop apps because they are handled separately in menus.
const themeOptions = () => {
const output = {};
output[Setting.THEME_LIGHT] = _('Light');
output[Setting.THEME_DARK] = _('Dark');
if (platform !== mobilePlatform) {
output[Setting.THEME_DRACULA] = _('Dracula');
output[Setting.THEME_SOLARIZED_LIGHT] = _('Solarised Light');
output[Setting.THEME_SOLARIZED_DARK] = _('Solarised Dark');
output[Setting.THEME_NORD] = _('Nord');
} else {
output[Setting.THEME_OLED_DARK] = _('OLED Dark');
}
return output;
};
this.metadata_ = {
'clientId': {
value: '',
@ -228,30 +243,58 @@ class Setting extends BaseModel {
return options;
},
},
theme: {
value: Setting.THEME_LIGHT,
type: Setting.TYPE_INT,
public: true,
appTypes: ['mobile', 'desktop'],
show: (settings) => {
return !settings['themeAutoDetect'];
},
isEnum: true,
label: () => _('Theme'),
section: 'appearance',
options: () => {
const output = {};
output[Setting.THEME_LIGHT] = _('Light');
output[Setting.THEME_DARK] = _('Dark');
if (platform !== mobilePlatform) {
output[Setting.THEME_DRACULA] = _('Dracula');
output[Setting.THEME_SOLARIZED_LIGHT] = _('Solarised Light');
output[Setting.THEME_SOLARIZED_DARK] = _('Solarised Dark');
output[Setting.THEME_NORD] = _('Nord');
output[Setting.THEME_ARITIM_DARK] = _('Aritim Dark');
} else {
output[Setting.THEME_OLED_DARK] = _('OLED Dark');
}
return output;
},
options: () => themeOptions(),
},
themeAutoDetect: {
value: false,
type: Setting.TYPE_BOOL,
section: 'appearance',
appTypes: ['desktop'],
public: true,
label: () => _('Automatically switch theme to match system theme'),
},
preferredLightTheme: {
value: Setting.THEME_LIGHT,
type: Setting.TYPE_INT,
public: true,
show: (settings) => {
return settings['themeAutoDetect'];
},
appTypes: ['desktop'],
isEnum: true,
label: () => _('Preferred light theme'),
section: 'appearance',
options: () => themeOptions(),
},
preferredDarkTheme: {
value: Setting.THEME_DARK,
type: Setting.TYPE_INT,
public: true,
show: (settings) => {
return settings['themeAutoDetect'];
},
appTypes: ['desktop'],
isEnum: true,
label: () => _('Preferred dark theme'),
section: 'appearance',
options: () => themeOptions(),
},
showNoteCounts: { value: true, type: Setting.TYPE_BOOL, public: true, advanced: true, appTypes: ['desktop'], label: () => _('Show note counts') },
layoutButtonSequence: {
value: Setting.LAYOUT_ALL,