mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-13 11:29:53 +03:00
Merge pull request #2041 from Scavanger/Electron-Fixes2
[Electron] Fixes and Adjustments
This commit is contained in:
commit
0a3fbae674
15 changed files with 96 additions and 64 deletions
|
@ -1,4 +1,6 @@
|
|||
'use strict';
|
||||
const { dialog } = require("@electron/remote");
|
||||
|
||||
|
||||
const CONFIGURATOR = require('./data_storage');
|
||||
const Switchery = require('./libraries/switchery/switchery')
|
||||
|
@ -529,6 +531,13 @@ GUI_control.prototype.update_dataflash_global = function () {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Don't use alert() in Electron, it has a nasty bug: https://github.com/electron/electron/issues/31917
|
||||
*/
|
||||
GUI_control.prototype.alert = function(message) {
|
||||
dialog.showMessageBoxSync({ message: message, icon: "./images/inav_icon_128.png" });
|
||||
}
|
||||
|
||||
// initialize object into GUI variable
|
||||
var GUI = new GUI_control();
|
||||
|
||||
|
|
26
js/main.js
26
js/main.js
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
const { app, BrowserWindow, ipcMain, Menu, MenuItem } = require('electron');
|
||||
const windowStateKeeper = require('electron-window-state');
|
||||
const path = require('path');
|
||||
const Store = require('electron-store');
|
||||
|
@ -53,6 +53,10 @@ function createDeviceChooser() {
|
|||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
createWindow();
|
||||
});
|
||||
|
||||
function createWindow() {
|
||||
|
||||
let mainWindowState = windowStateKeeper({
|
||||
defaultWidth: 800,
|
||||
|
@ -72,6 +76,24 @@ app.on('ready', () => {
|
|||
},
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('context-menu', (_, props) => {
|
||||
const menu = new Menu() ;
|
||||
menu.append(new MenuItem({ label: "Undo", role: "undo", accelerator: 'CmdOrCtrl+Z', visible: props.isEditable }));
|
||||
menu.append(new MenuItem({ label: "Redo", role: "redo", accelerator: 'CmdOrCtrl+Y', visible: props.isEditable }));
|
||||
menu.append(new MenuItem({ type: "separator", visible: props.isEditable }));
|
||||
menu.append(new MenuItem({ label: 'Cut', role: 'cut', accelerator: 'CmdOrCtrl+X', visible: props.isEditable && props.selectionText }));
|
||||
menu.append(new MenuItem({ label: 'Copy', role: 'copy', accelerator: 'CmdOrCtrl+C', visible: props.selectionText }));
|
||||
menu.append(new MenuItem({ label: 'Paste', role: 'paste', accelerator: 'CmdOrCtrl+V', visible: props.isEditable }));
|
||||
menu.append(new MenuItem({ label: "Select all", role: 'selectAll', accelerator: 'CmdOrCtrl+A', visible: props.isEditable}));
|
||||
|
||||
menu.items.forEach(item => {
|
||||
if (item.visible) {
|
||||
menu.popup();
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('select-bluetooth-device', (event, deviceList, callback) => {
|
||||
event.preventDefault();
|
||||
selectBluetoothCallback = callback;
|
||||
|
@ -147,7 +169,7 @@ app.on('ready', () => {
|
|||
if (process.env.NODE_ENV === 'development') {
|
||||
mainWindow.webContents.openDevTools();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
|
||||
|
|
|
@ -922,7 +922,7 @@ var mspHelper = (function () {
|
|||
|
||||
directions = [];
|
||||
for (directionLetterIndex = 0; directionLetterIndex < MSP.ledDirectionLetters.length; directionLetterIndex++) {
|
||||
if (bit_check(directionMask, directionLetterIndex)) {
|
||||
if (BitHelper.bit_check(directionMask, directionLetterIndex)) {
|
||||
directions.push(MSP.ledDirectionLetters[directionLetterIndex]);
|
||||
}
|
||||
}
|
||||
|
@ -932,7 +932,7 @@ var mspHelper = (function () {
|
|||
|
||||
functions = [];
|
||||
for (var functionLetterIndex = 0; functionLetterIndex < MSP.ledFunctionLetters.length; functionLetterIndex++) {
|
||||
if (bit_check(functionMask, functionLetterIndex)) {
|
||||
if (BitHelper.bit_check(functionMask, functionLetterIndex)) {
|
||||
functions.push(MSP.ledFunctionLetters[functionLetterIndex]);
|
||||
}
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ var mspHelper = (function () {
|
|||
|
||||
var overlayMask = (mask >> 12) & 0x3F;
|
||||
for (var overlayLetterIndex = 0; overlayLetterIndex < MSP.ledOverlayLetters.length; overlayLetterIndex++) {
|
||||
if (bit_check(overlayMask, overlayLetterIndex)) {
|
||||
if (BitHelper.bit_check(overlayMask, overlayLetterIndex)) {
|
||||
functions.push(MSP.ledOverlayLetters[overlayLetterIndex]);
|
||||
}
|
||||
}
|
||||
|
@ -971,7 +971,7 @@ var mspHelper = (function () {
|
|||
|
||||
directions = [];
|
||||
for (directionLetterIndex = 0; directionLetterIndex < MSP.ledDirectionLetters.length; directionLetterIndex++) {
|
||||
if (bit_check(directionMask, directionLetterIndex)) {
|
||||
if (BitHelper.bit_check(directionMask, directionLetterIndex)) {
|
||||
directions.push(MSP.ledDirectionLetters[directionLetterIndex]);
|
||||
}
|
||||
}
|
||||
|
@ -1017,7 +1017,7 @@ var mspHelper = (function () {
|
|||
|
||||
var overlayMask = (mask >> 16) & 0xFF;
|
||||
for (var overlayLetterIndex = 0; overlayLetterIndex < MSP.ledOverlayLetters.length; overlayLetterIndex++) {
|
||||
if (bit_check(overlayMask, overlayLetterIndex)) {
|
||||
if (BitHelper.bit_check(overlayMask, overlayLetterIndex)) {
|
||||
functions.push(MSP.ledOverlayLetters[overlayLetterIndex]);
|
||||
}
|
||||
}
|
||||
|
@ -1026,7 +1026,7 @@ var mspHelper = (function () {
|
|||
|
||||
directions = [];
|
||||
for (directionLetterIndex = 0; directionLetterIndex < MSP.ledDirectionLetters.length; directionLetterIndex++) {
|
||||
if (bit_check(directionMask, directionLetterIndex)) {
|
||||
if (BitHelper.bit_check(directionMask, directionLetterIndex)) {
|
||||
directions.push(MSP.ledDirectionLetters[directionLetterIndex]);
|
||||
}
|
||||
}
|
||||
|
@ -2260,7 +2260,7 @@ var mspHelper = (function () {
|
|||
buffer.push(BitHelper.lowByte(servoConfiguration.middle));
|
||||
buffer.push(BitHelper.highByte(servoConfiguration.middle));
|
||||
|
||||
buffer.push(lowByte(servoConfiguration.rate));
|
||||
buffer.push(BitHelper.lowByte(servoConfiguration.rate));
|
||||
|
||||
// prepare for next iteration
|
||||
servoIndex++;
|
||||
|
@ -2650,7 +2650,7 @@ var mspHelper = (function () {
|
|||
|
||||
bitIndex = MSP.ledOverlayLetters.indexOf(led.functions[overlayLetterIndex]);
|
||||
if (bitIndex >= 0) {
|
||||
mask |= bit_set(mask, bitIndex + 16);
|
||||
mask |= BitHelper.bit_set(mask, bitIndex + 16);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2662,9 +2662,9 @@ var mspHelper = (function () {
|
|||
bitIndex = MSP.ledDirectionLetters.indexOf(led.directions[directionLetterIndex]);
|
||||
if (bitIndex >= 0) {
|
||||
if(bitIndex < 4) {
|
||||
mask |= bit_set(mask, bitIndex + 28);
|
||||
mask |= BitHelper.bit_set(mask, bitIndex + 28);
|
||||
} else {
|
||||
extra |= bit_set(extra, bitIndex - 4);
|
||||
extra |= BitHelper.bit_set(extra, bitIndex - 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue