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: {
|
|
|
|
notifications: true,
|
|
|
|
api: true,
|
2019-11-03 18:52:15 +01:00
|
|
|
playBackControl: true,
|
2019-11-03 20:22:59 +01:00
|
|
|
menuBar: true,
|
2019-11-03 11:18:01 +01:00
|
|
|
apiSettings: {
|
|
|
|
port: 47836,
|
|
|
|
},
|
2020-10-07 20:10:31 +02:00
|
|
|
trayIcon: true,
|
2020-10-04 11:52:08 +02:00
|
|
|
mpris: false,
|
2021-01-10 13:52:22 +01:00
|
|
|
enableCustomHotkeys: false,
|
2019-11-03 11:18:01 +01:00
|
|
|
windowBounds: { width: 800, height: 600 },
|
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({
|
|
|
|
width: 500,
|
|
|
|
height: 600,
|
|
|
|
show: false,
|
|
|
|
frame: false,
|
|
|
|
title: "Tidal-hifi - settings",
|
|
|
|
webPreferences: {
|
|
|
|
affinity: "window",
|
|
|
|
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;
|