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

View File

@@ -26,6 +26,7 @@ export interface Settings {
downloadVideos: boolean // If background videos should be downloaded
theme: typeof themes[number] // The name of the currently enabled UI theme
customTheme: ThemeColors | null // The colors of a custom theme
customThemePath: string | null // The last folder that contained the `customTheme`'s file
libraryPath: string | undefined // The path to the user's library
isSng: boolean // If the chart should be downloaded as a .sng file or as a chart folder
isCompactTable: boolean // If the search result table should have reduced padding
@@ -41,6 +42,7 @@ export const defaultSettings: Settings = {
downloadVideos: true,
theme: 'dark',
customTheme: null,
customThemePath: null,
libraryPath: undefined,
isSng: false,
isCompactTable: false,