diff --git a/gui/package.json b/gui/package.json index e7227173..67603307 100644 --- a/gui/package.json +++ b/gui/package.json @@ -32,7 +32,7 @@ "@electron/osx-sign": "^1.0.4", "@popperjs/core": "^2.11.6", "blob-util": "^2.0.2", - "bootstrap": "^5.2.3", + "bootstrap": "^5.3.0-alpha.1", "bootstrap-icons": "^1.10.3", "bootswatch": "^5.2.3", "browser-image-compression": "^2.0.0", diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 37c4d002..bb60779e 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -144,14 +144,7 @@ updateAllChat(false); // WINDOW LISTENER window.addEventListener("DOMContentLoaded", () => { // theme selector - if (config.theme != "default") { - var theme_path = - "../node_modules/bootswatch/dist/" + config.theme + "/bootstrap.min.css"; - document.getElementById("bootstrap_theme").href = theme_path; - } else { - var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; - document.getElementById("bootstrap_theme").href = theme_path; - } + changeGuiDesign(config.theme); const userInfoFields = [ "user_info_image", @@ -975,7 +968,7 @@ update_chat = function (obj) { -

+

${filename} ${filesize} @@ -986,7 +979,7 @@ update_chat = function (obj) { } else { var fileheader = `

-

+

${filename} ${filesize} @@ -998,9 +991,9 @@ update_chat = function (obj) { var controlarea_transmit = `

- - - + + +
`; @@ -1008,8 +1001,8 @@ update_chat = function (obj) { var controlarea_receive = `
- - + +
`; @@ -1019,13 +1012,13 @@ update_chat = function (obj) { var filetype = "text/plain"; var controlarea_transmit = `
- - + +
`; var controlarea_receive = `
- +
`; } @@ -1221,7 +1214,7 @@ update_chat = function (obj) { + }" class="btn btn-sm btn-light p-0" style="height:20px;width:30px">-->

@@ -2236,3 +2229,59 @@ function sendFileReq(dxcall, file) { file: file, }); } + +function changeGuiDesign(design) { + console.log(design); + if ( + design != "default" && + design != "default_light" && + design != "default_dark" && + design != "default_auto" + ) { + var theme_path = + "../node_modules/bootswatch/dist/" + design + "/bootstrap.min.css"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + } else if (design == "default" || design == "default_light") { + var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + document.documentElement.setAttribute("data-bs-theme", "light"); + } else if (design == "default_dark") { + var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + document.querySelector("html").setAttribute("data-bs-theme", "dark"); + } else if (design == "default_auto") { + var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + + // https://stackoverflow.com/a/57795495 + // check if dark mode or light mode used in OS + if ( + window.matchMedia && + window.matchMedia("(prefers-color-scheme: dark)").matches + ) { + // dark mode + document.documentElement.setAttribute("data-bs-theme", "dark"); + } else { + document.documentElement.setAttribute("data-bs-theme", "light"); + } + + // also register event listener for automatic change + window + .matchMedia("(prefers-color-scheme: dark)") + .addEventListener("change", (event) => { + let newColorScheme = event.matches ? "dark" : "light"; + if (newColorScheme == "dark") { + document.documentElement.setAttribute("data-bs-theme", "dark"); + } else { + document.documentElement.setAttribute("data-bs-theme", "light"); + } + }); + } else { + var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + document.documentElement.setAttribute("data-bs-theme", "light"); + } + + //update path to css file + document.getElementById("bootstrap_theme").href = escape(theme_path); +} diff --git a/gui/preload-main.js b/gui/preload-main.js index e68fcee9..fbc99209 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -337,17 +337,7 @@ window.addEventListener("DOMContentLoaded", () => { document.getElementById("autoTuneSwitch").checked = false; } // theme selector - - if (config.theme != "default") { - var theme_path = - "../node_modules/bootswatch/dist/" + config.theme + "/bootstrap.min.css"; - document.getElementById("theme_selector").value = config.theme; - document.getElementById("bootstrap_theme").href = escape(theme_path); - } else { - var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; - document.getElementById("theme_selector").value = "default"; - document.getElementById("bootstrap_theme").href = escape(theme_path); - } + changeGuiDesign(config.theme); // Update channel selector document.getElementById("update_channel_selector").value = @@ -1161,7 +1151,9 @@ window.addEventListener("DOMContentLoaded", () => { }); // Theme selector clicked + document.getElementById("theme_selector").addEventListener("change", () => { + /* var theme = document.getElementById("theme_selector").value; if (theme != "default") { var theme_path = @@ -1169,10 +1161,9 @@ window.addEventListener("DOMContentLoaded", () => { } else { var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; } - - //update path to css file - document.getElementById("bootstrap_theme").href = escape(theme_path); - +*/ + var theme = document.getElementById("theme_selector").value; + changeGuiDesign(theme); config.theme = theme; //fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); FD.saveConfig(config, configPath); @@ -3368,3 +3359,66 @@ function loadSettings(elements) { config = data; }); } + +function changeGuiDesign(design) { + if ( + design != "default" && + design != "default_light" && + design != "default_dark" && + design != "default_auto" + ) { + var theme_path = + "../node_modules/bootswatch/dist/" + design + "/bootstrap.min.css"; + document.getElementById("theme_selector").value = design; + document.getElementById("bootstrap_theme").href = escape(theme_path); + } else if (design == "default" || design == "default_light") { + var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; + document.getElementById("theme_selector").value = "default_light"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + + document.documentElement.setAttribute("data-bs-theme", "light"); + } else if (design == "default_dark") { + var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; + document.getElementById("theme_selector").value = "default_dark"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + + document.querySelector("html").setAttribute("data-bs-theme", "dark"); + } else if (design == "default_auto") { + var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; + document.getElementById("theme_selector").value = "default_auto"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + + // https://stackoverflow.com/a/57795495 + // check if dark mode or light mode used in OS + if ( + window.matchMedia && + window.matchMedia("(prefers-color-scheme: dark)").matches + ) { + // dark mode + document.documentElement.setAttribute("data-bs-theme", "dark"); + } else { + document.documentElement.setAttribute("data-bs-theme", "light"); + } + + // also register event listener for automatic change + window + .matchMedia("(prefers-color-scheme: dark)") + .addEventListener("change", (event) => { + let newColorScheme = event.matches ? "dark" : "light"; + if (newColorScheme == "dark") { + document.documentElement.setAttribute("data-bs-theme", "dark"); + } else { + document.documentElement.setAttribute("data-bs-theme", "light"); + } + }); + } else { + var theme_path = "../node_modules/bootstrap/dist/css/bootstrap.min.css"; + document.getElementById("theme_selector").value = "default_light"; + document.getElementById("bootstrap_theme").href = escape(theme_path); + + document.documentElement.setAttribute("data-bs-theme", "light"); + } + + //update path to css file + document.getElementById("bootstrap_theme").href = escape(theme_path); +} diff --git a/gui/src/chat-module.html b/gui/src/chat-module.html index 5f64f0b6..a8760f2a 100644 --- a/gui/src/chat-module.html +++ b/gui/src/chat-module.html @@ -1,5 +1,5 @@ - + @@ -48,7 +48,7 @@
-
+
@@ -284,11 +284,11 @@
-
+
@@ -299,10 +299,10 @@ placeholder="Message - Send with [Enter]" > -
+
@@ -311,10 +311,7 @@ id="sendMessage" type="button" > - +
@@ -346,7 +343,7 @@ />
diff --git a/gui/src/index.html b/gui/src/index.html index f75fec6a..a6650cad 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -1,5 +1,5 @@ - + @@ -24,7 +24,7 @@ -
@@ -273,21 +270,18 @@
-
-
- AUDIO +
+
+
+ AUDIO +
-
+ +
- +
-
+
- TNC RIG CONTROL
-
+

@@ -421,41 +409,43 @@ />

- Rigctld application - - - - +
+ Rigctld application + + + + +
@@ -481,8 +471,10 @@ id="collapseSecondRow" >
-
-
MY STATION
+
+
+ MY STATION +
@@ -497,7 +489,7 @@ - +
-
-
+
+
UPDATER
@@ -630,12 +619,9 @@
-
+
- + AUDIO LEVEL
-
-
+
+
PING, CQ & BEACON
@@ -879,7 +865,7 @@
-
+
-
+
-
+
HEARD STATIONS
@@ -1035,10 +1020,7 @@ id="openReceivedFilesFolder" type="button" > - +
Filetransfer
-
@@ -1263,7 +1233,9 @@
-
@@ -1495,10 +1452,7 @@
- + - + - + + + @@ -1794,7 +1747,7 @@
-