2023-05-07 15:45:45 +02:00
|
|
|
import Store from "electron-store";
|
2023-05-01 23:23:43 +02:00
|
|
|
|
2023-05-07 15:45:45 +02:00
|
|
|
import { settings } from "../constants/settings";
|
|
|
|
import path from "path";
|
|
|
|
import { BrowserWindow } from "electron";
|
2019-11-03 18:52:15 +01:00
|
|
|
|
2023-05-07 15:45:45 +02:00
|
|
|
let settingsWindow: BrowserWindow;
|
2019-11-03 11:18:01 +01:00
|
|
|
|
2023-05-07 15:45:45 +02:00
|
|
|
export const settingsStore = new Store({
|
2019-11-03 11:18:01 +01:00
|
|
|
defaults: {
|
2023-04-20 19:07:44 +02:00
|
|
|
adBlock: false,
|
2023-04-27 11:35:00 +02:00
|
|
|
api: true,
|
2019-11-03 11:18:01 +01:00
|
|
|
apiSettings: {
|
|
|
|
port: 47836,
|
|
|
|
},
|
2023-04-27 14:13:32 +02:00
|
|
|
customCSS: "",
|
2023-04-27 11:35:00 +02:00
|
|
|
disableBackgroundThrottle: true,
|
2022-04-23 22:59:32 +02:00
|
|
|
disableHardwareMediaKeys: false,
|
2021-01-10 13:52:22 +01:00
|
|
|
enableCustomHotkeys: false,
|
2021-04-19 20:43:25 +02:00
|
|
|
enableDiscord: false,
|
2022-05-07 18:13:36 +02:00
|
|
|
flags: {
|
|
|
|
gpuRasterization: true,
|
|
|
|
disableHardwareMediaKeys: false,
|
|
|
|
},
|
2023-04-27 11:35:00 +02:00
|
|
|
menuBar: true,
|
|
|
|
minimizeOnClose: false,
|
|
|
|
mpris: false,
|
|
|
|
notifications: true,
|
|
|
|
playBackControl: true,
|
|
|
|
singleInstance: true,
|
|
|
|
skipArtists: false,
|
|
|
|
skippedArtists: [""],
|
2023-05-09 23:57:16 +02:00
|
|
|
theme: "none",
|
2023-04-27 11:35:00 +02:00
|
|
|
trayIcon: true,
|
|
|
|
updateFrequency: 500,
|
|
|
|
windowBounds: { width: 800, height: 600 },
|
2022-05-07 18:13:36 +02:00
|
|
|
},
|
|
|
|
migrations: {
|
|
|
|
"3.1.0": (migrationStore) => {
|
|
|
|
console.log("running migrations for 3.1.0");
|
|
|
|
migrationStore.set(
|
|
|
|
settings.flags.disableHardwareMediaKeys,
|
|
|
|
migrationStore.get("disableHardwareMediaKeys") ?? false
|
|
|
|
);
|
|
|
|
},
|
2019-10-30 22:49:04 +01:00
|
|
|
},
|
2019-11-03 11:18:01 +01:00
|
|
|
});
|
2019-10-30 22:49:04 +01:00
|
|
|
|
|
|
|
const settingsModule = {
|
2023-05-07 15:45:45 +02:00
|
|
|
// settings,
|
2019-11-03 18:52:15 +01:00
|
|
|
settingsWindow,
|
|
|
|
};
|
|
|
|
|
2023-05-07 15:45:45 +02:00
|
|
|
export const createSettingsWindow = function () {
|
2019-11-03 18:52:15 +01:00
|
|
|
settingsWindow = new BrowserWindow({
|
2022-09-25 12:50:41 +02:00
|
|
|
width: 700,
|
2019-11-03 18:52:15 +01:00
|
|
|
height: 600,
|
2022-09-25 12:50:41 +02:00
|
|
|
resizable: false,
|
2019-11-03 18:52:15 +01:00
|
|
|
show: false,
|
2022-09-25 12:50:41 +02:00
|
|
|
transparent: true,
|
2019-11-03 18:52:15 +01:00
|
|
|
frame: false,
|
2022-09-25 12:50:41 +02:00
|
|
|
title: "TIDAL Hi-Fi settings",
|
2019-11-03 18:52:15 +01:00
|
|
|
webPreferences: {
|
|
|
|
preload: path.join(__dirname, "../pages/settings/preload.js"),
|
|
|
|
plugins: true,
|
|
|
|
nodeIntegration: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-05-13 22:45:15 +02:00
|
|
|
settingsWindow.on("close", (event: Event) => {
|
2019-11-03 18:52:15 +01:00
|
|
|
if (settingsWindow != null) {
|
|
|
|
event.preventDefault();
|
|
|
|
settingsWindow.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
settingsWindow.loadURL(`file://${__dirname}/../pages/settings/settings.html`);
|
|
|
|
|
|
|
|
settingsModule.settingsWindow = settingsWindow;
|
|
|
|
};
|
|
|
|
|
2023-05-07 15:45:45 +02:00
|
|
|
export const showSettingsWindow = function (tab = "general") {
|
2019-11-03 20:22:59 +01:00
|
|
|
settingsWindow.webContents.send("goToTab", tab);
|
|
|
|
|
2019-11-03 18:52:15 +01:00
|
|
|
// refresh data just before showing the window
|
|
|
|
settingsWindow.webContents.send("refreshData");
|
|
|
|
settingsWindow.show();
|
|
|
|
};
|
2023-05-07 15:45:45 +02:00
|
|
|
export const hideSettingsWindow = function () {
|
2019-11-03 18:52:15 +01:00
|
|
|
settingsWindow.hide();
|
|
|
|
};
|
|
|
|
|
2023-05-07 15:45:45 +02:00
|
|
|
export const closeSettingsWindow = function () {
|
2019-11-03 18:52:15 +01:00
|
|
|
settingsWindow = null;
|
2019-10-30 22:49:04 +01:00
|
|
|
};
|