2019-11-03 11:18:01 +01:00
|
|
|
const Store = require("electron-store");
|
|
|
|
const settings = require("./../constants/settings");
|
2019-11-03 18:52:15 +01:00
|
|
|
const path = require("path");
|
|
|
|
const { BrowserWindow } = require("electron");
|
|
|
|
|
|
|
|
let settingsWindow;
|
2019-11-03 11:18:01 +01:00
|
|
|
|
|
|
|
const store = new Store({
|
|
|
|
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 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: [""],
|
|
|
|
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 = {
|
2019-11-03 11:18:01 +01:00
|
|
|
store,
|
2019-10-30 22:49:04 +01:00
|
|
|
settings,
|
2019-11-03 18:52:15 +01:00
|
|
|
settingsWindow,
|
|
|
|
};
|
|
|
|
|
2020-10-04 11:52:08 +02:00
|
|
|
settingsModule.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,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
settingsWindow.on("close", (event) => {
|
|
|
|
if (settingsWindow != null) {
|
|
|
|
event.preventDefault();
|
|
|
|
settingsWindow.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
settingsWindow.loadURL(`file://${__dirname}/../pages/settings/settings.html`);
|
|
|
|
|
|
|
|
settingsModule.settingsWindow = settingsWindow;
|
|
|
|
};
|
|
|
|
|
2020-10-04 11:52:08 +02:00
|
|
|
settingsModule.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();
|
|
|
|
};
|
2020-10-04 11:52:08 +02:00
|
|
|
settingsModule.hideSettingsWindow = function () {
|
2019-11-03 18:52:15 +01:00
|
|
|
settingsWindow.hide();
|
|
|
|
};
|
|
|
|
|
2020-10-04 11:52:08 +02:00
|
|
|
settingsModule.closeSettingsWindow = function () {
|
2019-11-03 18:52:15 +01:00
|
|
|
settingsWindow = null;
|
2019-10-30 22:49:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = settingsModule;
|