Remember custom theme path

This commit is contained in:
Geomitron
2024-07-12 12:26:51 -05:00
parent d6373194a6
commit 452111c1ef
3 changed files with 13 additions and 2 deletions

View File

@@ -79,7 +79,7 @@ export class SettingsComponent implements OnInit {
async getCustomTheme() {
const result = await window.electron.invoke.showOpenDialog({
title: 'Choose custom theme',
defaultPath: this.settingsService.libraryDirectory || '',
defaultPath: this.settingsService.customThemePath || '',
properties: ['openFile'],
filters: [
{ name: "Themes", extensions: ["json"] },
@@ -87,10 +87,12 @@ export class SettingsComponent implements OnInit {
})
if (result.canceled === false) {
const newThemeColors = await window.electron.invoke.getThemeColors(result.filePaths[0])
const path = result.filePaths[0].replace(/\\/g, '/')
const newThemeColors = await window.electron.invoke.getThemeColors(path)
if (newThemeColors) {
this.settingsService.customTheme = newThemeColors
this.settingsService.customThemePath = path.substring(0, path.lastIndexOf('/'))
} else {
alert(`ERROR: ${result.filePaths[0]} was not a valid JSON file.`)
}

View File

@@ -96,6 +96,13 @@ export class SettingsService {
this.settings.customTheme = value
this.saveSettings()
}
get customThemePath() {
return this.settings.customThemePath
}
set customThemePath(value: string | null) {
this.settings.customThemePath = value
this.saveSettings()
}
get isSng() {
return this.settings.isSng