From cb8667bd41c1f4c0068b82012ecfaf3122941bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Marmie?= Date: Mon, 21 Oct 2024 18:14:28 -0300 Subject: [PATCH 1/2] feat: Added ability to keep a static window title. --- src/constants/settings.ts | 1 + src/pages/settings/preload.ts | 4 ++++ src/pages/settings/settings.html | 10 ++++++++++ src/preload.ts | 4 +++- src/scripts/settings.ts | 9 +++++---- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/constants/settings.ts b/src/constants/settings.ts index 78fce85..3159117 100644 --- a/src/constants/settings.ts +++ b/src/constants/settings.ts @@ -57,6 +57,7 @@ export const settings = { skippedArtists: "skippedArtists", theme: "theme", trayIcon: "trayIcon", + staticWindowTitle: "staticWindowTitle", updateFrequency: "updateFrequency", windowBounds: { root: "windowBounds", diff --git a/src/pages/settings/preload.ts b/src/pages/settings/preload.ts index 498988b..53286e1 100644 --- a/src/pages/settings/preload.ts +++ b/src/pages/settings/preload.ts @@ -48,6 +48,7 @@ let adBlock: HTMLInputElement, skippedArtists: HTMLInputElement, theme: HTMLSelectElement, trayIcon: HTMLInputElement, + staticWindowTitle: HTMLInputElement, updateFrequency: HTMLInputElement, enableListenBrainz: HTMLInputElement, ListenBrainzAPI: HTMLInputElement, @@ -143,6 +144,7 @@ function refreshSettings() { theme.value = settingsStore.get(settings.theme); skippedArtists.value = settingsStore.get(settings.skippedArtists).join("\n"); trayIcon.checked = settingsStore.get(settings.trayIcon); + staticWindowTitle.checked = settingsStore.get(settings.staticWindowTitle); updateFrequency.value = settingsStore.get(settings.updateFrequency); enableListenBrainz.checked = settingsStore.get(settings.ListenBrainz.enabled); ListenBrainzAPI.value = settingsStore.get(settings.ListenBrainz.api); @@ -259,6 +261,7 @@ window.addEventListener("DOMContentLoaded", () => { port = get("port"); theme = get("themesList"); trayIcon = get("trayIcon"); + staticWindowTitle = get("staticWindowTitle"); skipArtists = get("skipArtists"); skippedArtists = get("skippedArtists"); singleInstance = get("singleInstance"); @@ -298,6 +301,7 @@ window.addEventListener("DOMContentLoaded", () => { addInputListener(singleInstance, settings.singleInstance); addSelectListener(theme, settings.theme); addInputListener(trayIcon, settings.trayIcon); + addInputListener(staticWindowTitle, settings.staticWindowTitle); addInputListener(updateFrequency, settings.updateFrequency); addInputListener( enableListenBrainz, diff --git a/src/pages/settings/settings.html b/src/pages/settings/settings.html index 30e839b..f0b0dfb 100644 --- a/src/pages/settings/settings.html +++ b/src/pages/settings/settings.html @@ -106,6 +106,16 @@ +
+
+

Static Window Title

+

Makes the window title "TIDAL Hi-Fi" instead of changing to the currently playing song.

+
+ +

Minimize on Close

diff --git a/src/preload.ts b/src/preload.ts index 814044b..bfd472d 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -550,6 +550,7 @@ setInterval(function () { const artistsArray = elements.getArtistsArray(); const artistsString = elements.getArtistsString(artistsArray); const songDashArtistTitle = `${title} - ${artistsString}`; + const staticTitle = "TIDAL Hi-Fi" const titleOrArtistsChanged = currentSong !== songDashArtistTitle; const current = elements.getText("current"); const currentStatus = getCurrentlyPlayingStatus(); @@ -594,7 +595,8 @@ setInterval(function () { }; // update title, url and play info with new info - setTitle(songDashArtistTitle); + if(settingsStore.get(settings.staticWindowTitle)) setTitle(staticTitle) + else setTitle(songDashArtistTitle); getTrackURL(); currentSong = songDashArtistTitle; currentPlayStatus = currentStatus; diff --git a/src/scripts/settings.ts b/src/scripts/settings.ts index 4e5323a..7416b1f 100644 --- a/src/scripts/settings.ts +++ b/src/scripts/settings.ts @@ -71,6 +71,7 @@ export const settingsStore = new Store({ skippedArtists: [""], theme: "none", trayIcon: true, + staticWindowTitle: false, updateFrequency: 500, windowBounds: { width: 800, height: 600 }, }, @@ -127,7 +128,7 @@ const settingsModule = { settingsWindow, }; -export const createSettingsWindow = function () { +export const createSettingsWindow = function() { settingsWindow = new BrowserWindow({ width: 650, height: 700, @@ -159,7 +160,7 @@ export const createSettingsWindow = function () { settingsModule.settingsWindow = settingsWindow; }; -export const showSettingsWindow = function (tab = "general") { +export const showSettingsWindow = function(tab = "general") { if (!settingsWindow) { console.log("Settings window is not initialized. Attempting to create it."); createSettingsWindow(); @@ -170,11 +171,11 @@ export const showSettingsWindow = function (tab = "general") { settingsWindow.webContents.send("refreshData"); settingsWindow.show(); }; -export const hideSettingsWindow = function () { +export const hideSettingsWindow = function() { settingsWindow.hide(); }; -export const closeSettingsWindow = function () { +export const closeSettingsWindow = function() { settingsWindow = null; }; From 974877ea4f4bd1195e2639c6f026ccf1738ba0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Marmie?= Date: Wed, 23 Oct 2024 09:39:13 -0300 Subject: [PATCH 2/2] staticWindowTitle(fix): Order alphabetically on all appearances, change if to a ternary --- src/constants/settings.ts | 2 +- src/pages/settings/preload.ts | 10 +++++----- src/preload.ts | 3 +-- src/scripts/settings.ts | 10 +++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/constants/settings.ts b/src/constants/settings.ts index 3159117..242dd4c 100644 --- a/src/constants/settings.ts +++ b/src/constants/settings.ts @@ -55,9 +55,9 @@ export const settings = { singleInstance: "singleInstance", skipArtists: "skipArtists", skippedArtists: "skippedArtists", + staticWindowTitle: "staticWindowTitle", theme: "theme", trayIcon: "trayIcon", - staticWindowTitle: "staticWindowTitle", updateFrequency: "updateFrequency", windowBounds: { root: "windowBounds", diff --git a/src/pages/settings/preload.ts b/src/pages/settings/preload.ts index 53286e1..34eff23 100644 --- a/src/pages/settings/preload.ts +++ b/src/pages/settings/preload.ts @@ -46,9 +46,9 @@ let adBlock: HTMLInputElement, singleInstance: HTMLInputElement, skipArtists: HTMLInputElement, skippedArtists: HTMLInputElement, + staticWindowTitle: HTMLInputElement, theme: HTMLSelectElement, trayIcon: HTMLInputElement, - staticWindowTitle: HTMLInputElement, updateFrequency: HTMLInputElement, enableListenBrainz: HTMLInputElement, ListenBrainzAPI: HTMLInputElement, @@ -141,10 +141,10 @@ function refreshSettings() { port.value = settingsStore.get(settings.apiSettings.port); singleInstance.checked = settingsStore.get(settings.singleInstance); skipArtists.checked = settingsStore.get(settings.skipArtists); - theme.value = settingsStore.get(settings.theme); skippedArtists.value = settingsStore.get(settings.skippedArtists).join("\n"); - trayIcon.checked = settingsStore.get(settings.trayIcon); staticWindowTitle.checked = settingsStore.get(settings.staticWindowTitle); + theme.value = settingsStore.get(settings.theme); + trayIcon.checked = settingsStore.get(settings.trayIcon); updateFrequency.value = settingsStore.get(settings.updateFrequency); enableListenBrainz.checked = settingsStore.get(settings.ListenBrainz.enabled); ListenBrainzAPI.value = settingsStore.get(settings.ListenBrainz.api); @@ -261,9 +261,9 @@ window.addEventListener("DOMContentLoaded", () => { port = get("port"); theme = get("themesList"); trayIcon = get("trayIcon"); - staticWindowTitle = get("staticWindowTitle"); skipArtists = get("skipArtists"); skippedArtists = get("skippedArtists"); + staticWindowTitle = get("staticWindowTitle"); singleInstance = get("singleInstance"); updateFrequency = get("updateFrequency"); enableListenBrainz = get("enableListenBrainz"); @@ -298,10 +298,10 @@ window.addEventListener("DOMContentLoaded", () => { addInputListener(port, settings.apiSettings.port); addInputListener(skipArtists, settings.skipArtists); addTextAreaListener(skippedArtists, settings.skippedArtists); + addInputListener(staticWindowTitle, settings.staticWindowTitle); addInputListener(singleInstance, settings.singleInstance); addSelectListener(theme, settings.theme); addInputListener(trayIcon, settings.trayIcon); - addInputListener(staticWindowTitle, settings.staticWindowTitle); addInputListener(updateFrequency, settings.updateFrequency); addInputListener( enableListenBrainz, diff --git a/src/preload.ts b/src/preload.ts index bfd472d..a2b01a8 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -595,8 +595,7 @@ setInterval(function () { }; // update title, url and play info with new info - if(settingsStore.get(settings.staticWindowTitle)) setTitle(staticTitle) - else setTitle(songDashArtistTitle); + settingsStore.get(settings.staticWindowTitle) ? setTitle(staticTitle) : setTitle(songDashArtistTitle); getTrackURL(); currentSong = songDashArtistTitle; currentPlayStatus = currentStatus; diff --git a/src/scripts/settings.ts b/src/scripts/settings.ts index 7416b1f..30ea16d 100644 --- a/src/scripts/settings.ts +++ b/src/scripts/settings.ts @@ -69,9 +69,9 @@ export const settingsStore = new Store({ singleInstance: true, skipArtists: false, skippedArtists: [""], + staticWindowTitle: false, theme: "none", trayIcon: true, - staticWindowTitle: false, updateFrequency: 500, windowBounds: { width: 800, height: 600 }, }, @@ -128,7 +128,7 @@ const settingsModule = { settingsWindow, }; -export const createSettingsWindow = function() { +export const createSettingsWindow = function () { settingsWindow = new BrowserWindow({ width: 650, height: 700, @@ -160,7 +160,7 @@ export const createSettingsWindow = function() { settingsModule.settingsWindow = settingsWindow; }; -export const showSettingsWindow = function(tab = "general") { +export const showSettingsWindow = function (tab = "general") { if (!settingsWindow) { console.log("Settings window is not initialized. Attempting to create it."); createSettingsWindow(); @@ -171,11 +171,11 @@ export const showSettingsWindow = function(tab = "general") { settingsWindow.webContents.send("refreshData"); settingsWindow.show(); }; -export const hideSettingsWindow = function() { +export const hideSettingsWindow = function () { settingsWindow.hide(); }; -export const closeSettingsWindow = function() { +export const closeSettingsWindow = function () { settingsWindow = null; };