|
|
|
@ -1,9 +1,9 @@ |
|
|
|
|
"use strict"; |
|
|
|
|
|
|
|
|
|
const {ipcMain, app} = require("electron"); |
|
|
|
|
const fsn = require("fs"); |
|
|
|
|
const fs = require("fs/promises") |
|
|
|
|
const path = require("path"); |
|
|
|
|
const {ipcMain, app, dialog} = require("electron"); |
|
|
|
|
const fsn = require("fs"); |
|
|
|
|
const fs = require("fs/promises") |
|
|
|
|
const path = require("path"); |
|
|
|
|
|
|
|
|
|
class SettingsManager { |
|
|
|
|
app; |
|
|
|
@ -21,9 +21,10 @@ class SettingsManager { |
|
|
|
|
this.data = JSON.parse(fsn.readFileSync(SettingsManager.File, {encoding : "utf-8"})); |
|
|
|
|
|
|
|
|
|
ipcMain.handle("SettingsManager::resize", (_, height) => app.windowManager.windows.settings.setSize(800, height, true)); |
|
|
|
|
ipcMain.handle("SettingsManager::get", (_, key, defaultValue = null) => this.get(key, defaultValue)); |
|
|
|
|
ipcMain.handle("SettingsManager::set", (_, key, value) => this.set(key, value)); |
|
|
|
|
ipcMain.handle("SettingsManager::all", () => this.data); |
|
|
|
|
ipcMain.handle("SettingsManager::get", (_, key, defaultValue = null) => this.get(key, defaultValue)); |
|
|
|
|
ipcMain.handle("SettingsManager::set", (_, key, value) => this.set(key, value)); |
|
|
|
|
ipcMain.handle("SettingsManager::all", () => this.data); |
|
|
|
|
ipcMain.on("SettingsManager::reset", () => this.reset()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
get(key, defaultValue = null) { |
|
|
|
@ -46,6 +47,19 @@ class SettingsManager { |
|
|
|
|
this.change(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async reset() { |
|
|
|
|
const {response} = await dialog.showMessageBox(this.app.windowManager.windows.settings, { |
|
|
|
|
title : "Reset all settings", |
|
|
|
|
message : "Do you really want to revert ALL settings back to default?", |
|
|
|
|
buttons : ["yes", "no"], |
|
|
|
|
defaultId : 0 |
|
|
|
|
}); |
|
|
|
|
if (response === 1) |
|
|
|
|
return; |
|
|
|
|
this.data = {}; |
|
|
|
|
this.save(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static CheckFileSystem() { |
|
|
|
|
|
|
|
|
|
return fsn.existsSync(SettingsManager.Folder) && fsn.existsSync(SettingsManager.File); |
|
|
|
|