= ({ radio }) => {
});
};
+ const awaitEndOfRxForDeletion = (frequency: number): void => {
+ const interval = setInterval(
+ (frequency: number) => {
+ const radio = useRadioState
+ .getState()
+ .radios.find((r) => r.frequency === frequency);
+ if (!radio) {
+ clearInterval(interval);
+ return;
+ }
+
+ if (!radio.currentlyRx && !radio.currentlyTx) {
+ void window.api.removeFrequency(radio.frequency);
+ removeRadio(radio.frequency);
+ clearInterval(interval);
+ }
+ },
+ 60,
+ frequency
+ );
+
+ // Clear the interval after 5 seconds
+ setTimeout(() => {
+ clearInterval(interval);
+ }, 10000);
+ };
+
return (
<>
@@ -183,6 +212,12 @@ const Radio: React.FC = ({ radio }) => {
className="btn btn-no-interact"
style={{ height: "100%", marginBottom: "4%" }}
onClick={clickRadioHeader}
+ onKeyDown={(e) => {
+ if (e.key === "Delete" || e.key === "Backspace") {
+ awaitEndOfRxForDeletion(radio.frequency);
+ setPendingDeletion(radio.frequency, true);
+ }
+ }}
>
{radio.humanFrequency}
@@ -193,7 +228,7 @@ const Radio: React.FC = ({ radio }) => {
"btn",
!radio.xc && !radio.crossCoupleAcross && "btn-primary",
radio.xc && "btn-success",
- radio.crossCoupleAcross && "btn-warning",
+ radio.crossCoupleAcross && "btn-warning"
)}
style={{ width: "45%", height: "100%", marginTop: "4%" }}
onClick={clickXc}
@@ -206,7 +241,7 @@ const Radio: React.FC = ({ radio }) => {
className={clsx(
"btn",
!radio.onSpeaker && "btn-primary",
- radio.onSpeaker && "btn-success",
+ radio.onSpeaker && "btn-success"
)}
style={{
width: "45%",
@@ -232,7 +267,7 @@ const Radio: React.FC = ({ radio }) => {
"btn",
!radio.rx && "btn-primary",
radio.rx && radio.currentlyRx && "btn-warning",
- radio.rx && !radio.currentlyRx && "btn-success",
+ radio.rx && !radio.currentlyRx && "btn-success"
)}
style={{ width: "100%", height: "100%" }}
onClick={clickRx}
@@ -244,7 +279,7 @@ const Radio: React.FC = ({ radio }) => {
"btn",
!radio.tx && "btn-primary",
radio.tx && radio.currentlyTx && "btn-warning",
- radio.tx && !radio.currentlyTx && "btn-success",
+ radio.tx && !radio.currentlyTx && "btn-success"
)}
style={{ width: "100%", height: "100%", marginTop: "8%" }}
onClick={clickTx}
diff --git a/src/index.html b/src/index.html
index 474f62f..ed09806 100644
--- a/src/index.html
+++ b/src/index.html
@@ -7,6 +7,8 @@
http-equiv="Content-Security-Policy"
content="script-src 'self' 'unsafe-inline'"
/>
+
+
diff --git a/src/index.ts b/src/index.ts
index 3884b04..2a8f6c2 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -28,6 +28,7 @@ let version: string;
let mainWindow: BrowserWindow;
const defaultWindowSize = { width: 800, height: 660 };
+const savedLastWindowSize = { width: 800, height: 660 };
let currentConfiguration: Configuration = {
audioApi: -1,
@@ -58,6 +59,19 @@ const setAudioSettings = () => {
TrackAudioAfv.SetHardwareType(currentConfiguration.hardwareType || 0);
};
+const toggleMiniMode = () => {
+ if (
+ mainWindow.getSize()[0] == mainWindow.getMinimumSize()[0] &&
+ mainWindow.getSize()[1] == mainWindow.getMinimumSize()[1]
+ ) {
+ mainWindow.setSize(savedLastWindowSize.width, savedLastWindowSize.height);
+ return;
+ }
+ savedLastWindowSize.width = mainWindow.getSize()[0];
+ savedLastWindowSize.height = mainWindow.getSize()[1];
+ mainWindow.setSize(1, 1);
+};
+
const restoreWindowBounds = (win: BrowserWindow) => {
const savedBounds = store.get("bounds");
const boundsRectangle = savedBounds as Rectangle;
@@ -130,6 +144,17 @@ const createWindow = (): void => {
store.set("bounds", mainWindow.getBounds());
});
+
+ mainWindow.webContents.on("before-input-event", (e, input) => {
+ if (
+ input.key.toLowerCase() === "m" &&
+ input.type === "keyDown" &&
+ (input.control || input.meta)
+ ) {
+ toggleMiniMode();
+ e.preventDefault();
+ }
+ });
};
// This method will be called when Electron has finished
@@ -261,6 +286,10 @@ ipcMain.handle("set-audio-api", (_, apiId: number) => {
saveConfig();
});
+ipcMain.handle("toggle-mini-mode", () => {
+ toggleMiniMode();
+});
+
//
// AFV login settings
//
diff --git a/src/preload.ts b/src/preload.ts
index 56c34b6..428f581 100644
--- a/src/preload.ts
+++ b/src/preload.ts
@@ -89,6 +89,8 @@ const IElectronAPI = {
RequestPttKeyName: () => ipcRenderer.invoke("request-ptt-key-name"),
+ toggleMiniMode: () => ipcRenderer.invoke("toggle-mini-mode"),
+
dialog: (
type: "none" | "info" | "error" | "question" | "warning",
title: string,