mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-19 22:35:15 +03:00
[Electron] MacOs and MessageBox fix
MacOS: - Nice icon for DMG - Fix bug when Configurator was minimized and dock icon is clicked Fix (Workaround): After a MessageBox (alert()) was displayed, all input fields stopped working.
This commit is contained in:
parent
a4fd2bce9d
commit
2efebecb61
5 changed files with 36 additions and 22 deletions
|
@ -74,7 +74,8 @@ module.exports = {
|
||||||
name: '@electron-forge/maker-dmg',
|
name: '@electron-forge/maker-dmg',
|
||||||
config: {
|
config: {
|
||||||
name: "INAV Configurator",
|
name: "INAV Configurator",
|
||||||
background: "./assets/osx/dmg-background.png"
|
background: "./assets/osx/dmg-background.png",
|
||||||
|
icon: "./images/inav.icns"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
const { dialog } = require("@electron/remote");
|
||||||
|
|
||||||
|
|
||||||
const CONFIGURATOR = require('./data_storage');
|
const CONFIGURATOR = require('./data_storage');
|
||||||
const Switchery = require('./libraries/switchery/switchery')
|
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
|
// initialize object into GUI variable
|
||||||
var GUI = new GUI_control();
|
var GUI = new GUI_control();
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,10 @@ function createDeviceChooser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
|
createWindow();
|
||||||
|
});
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
|
||||||
let mainWindowState = windowStateKeeper({
|
let mainWindowState = windowStateKeeper({
|
||||||
defaultWidth: 800,
|
defaultWidth: 800,
|
||||||
|
@ -147,7 +151,7 @@ app.on('ready', () => {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
mainWindow.webContents.openDevTools();
|
mainWindow.webContents.openDevTools();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
|
|
||||||
|
|
|
@ -483,7 +483,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
function checkApproachAltitude(altitude, isSeaLevelRef, sealevel) {
|
function checkApproachAltitude(altitude, isSeaLevelRef, sealevel) {
|
||||||
|
|
||||||
if (altitude - (isSeaLevelRef ? sealevel * 100 : 0 ) < 0) {
|
if (altitude - (isSeaLevelRef ? sealevel * 100 : 0 ) < 0) {
|
||||||
alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
GUI.alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
function checkLandingAltitude(altitude, isSeaLevelRef, sealevel) {
|
function checkLandingAltitude(altitude, isSeaLevelRef, sealevel) {
|
||||||
|
|
||||||
if (altitude - (isSeaLevelRef ? sealevel * 100 : 0 ) < MAX_NEG_FW_LAND_ALT) {
|
if (altitude - (isSeaLevelRef ? sealevel * 100 : 0 ) < MAX_NEG_FW_LAND_ALT) {
|
||||||
alert(i18n.getMessage('MissionPlannerFwLAndingAltitudeChangeReset'));
|
GUI.alert(i18n.getMessage('MissionPlannerFwLAndingAltitudeChangeReset'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1489,26 +1489,26 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
if ($(this).val() >= 360 || ($(this).val() < 0 && $(this).val() != -1))
|
if ($(this).val() >= 360 || ($(this).val() < 0 && $(this).val() != -1))
|
||||||
{
|
{
|
||||||
$(this).val(-1);
|
$(this).val(-1);
|
||||||
alert(i18n.getMessage('MissionPlannerHeadSettingsCheck'));
|
GUI.alert(i18n.getMessage('MissionPlannerHeadSettingsCheck'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MWNP.WPTYPE.REV[element.getAction()] == "RTH") {
|
else if (MWNP.WPTYPE.REV[element.getAction()] == "RTH") {
|
||||||
if ($(this).val() != 0 && $(this).val() != 1)
|
if ($(this).val() != 0 && $(this).val() != 1)
|
||||||
{
|
{
|
||||||
$(this).val(0);
|
$(this).val(0);
|
||||||
alert(i18n.getMessage('MissionPlannerRTHSettingsCheck'));
|
GUI.alert(i18n.getMessage('MissionPlannerRTHSettingsCheck'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") {
|
else if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") {
|
||||||
if ($(this).val() > mission.getNonAttachedList().length || $(this).val() < 1)
|
if ($(this).val() > mission.getNonAttachedList().length || $(this).val() < 1)
|
||||||
{
|
{
|
||||||
$(this).val(1);
|
$(this).val(1);
|
||||||
alert(i18n.getMessage('MissionPlannerJumpSettingsCheck'));
|
GUI.alert(i18n.getMessage('MissionPlannerJumpSettingsCheck'));
|
||||||
}
|
}
|
||||||
else if (mission.getPoiList().length != 0 && mission.getPoiList()) {
|
else if (mission.getPoiList().length != 0 && mission.getPoiList()) {
|
||||||
if (mission.getPoiList().includes(mission.convertJumpNumberToWaypoint(Number($(this).val())-1))) {
|
if (mission.getPoiList().includes(mission.convertJumpNumberToWaypoint(Number($(this).val())-1))) {
|
||||||
$(this).val(1);
|
$(this).val(1);
|
||||||
alert(i18n.getMessage('MissionPlannerJump3SettingsCheck'));
|
GUI.alert(i18n.getMessage('MissionPlannerJump3SettingsCheck'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1523,7 +1523,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
if ($(this).val() > 10 || ($(this).val() < 0 && $(this).val() != -1))
|
if ($(this).val() > 10 || ($(this).val() < 0 && $(this).val() != -1))
|
||||||
{
|
{
|
||||||
$(this).val(0);
|
$(this).val(0);
|
||||||
alert(i18n.getMessage('MissionPlannerJump2SettingsCheck'));
|
GUI.alert(i18n.getMessage('MissionPlannerJump2SettingsCheck'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
element.setP2(Number($(this).val()));
|
element.setP2(Number($(this).val()));
|
||||||
|
@ -2310,7 +2310,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
let found = false;
|
let found = false;
|
||||||
mission.get().forEach(wp => {
|
mission.get().forEach(wp => {
|
||||||
if (wp.getAction() == MWNP.WPTYPE.LAND) {
|
if (wp.getAction() == MWNP.WPTYPE.LAND) {
|
||||||
alert(i18n.getMessage('MissionPlannerOnlyOneLandWp'));
|
GUI.alert(i18n.getMessage('MissionPlannerOnlyOneLandWp'));
|
||||||
found = true;
|
found = true;
|
||||||
$(event.currentTarget).val(selectedMarker.getAction());
|
$(event.currentTarget).val(selectedMarker.getAction());
|
||||||
}
|
}
|
||||||
|
@ -2684,7 +2684,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
|
|
||||||
$('#addSafehome').on('click', () => {
|
$('#addSafehome').on('click', () => {
|
||||||
if (FC.SAFEHOMES.safehomeCount() + 1 > FC.SAFEHOMES.getMaxSafehomeCount()){
|
if (FC.SAFEHOMES.safehomeCount() + 1 > FC.SAFEHOMES.getMaxSafehomeCount()){
|
||||||
alert(i18n.getMessage('missionSafehomeMaxSafehomesReached'));
|
GUI.alert(i18n.getMessage('missionSafehomeMaxSafehomesReached'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3016,7 +3016,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
$('#removePoint').on('click', function () {
|
$('#removePoint').on('click', function () {
|
||||||
if (selectedMarker) {
|
if (selectedMarker) {
|
||||||
if (mission.isJumpTargetAttached(selectedMarker)) {
|
if (mission.isJumpTargetAttached(selectedMarker)) {
|
||||||
alert(i18n.getMessage('MissionPlannerJumpTargetRemoval'));
|
GUI.alert(i18n.getMessage('MissionPlannerJumpTargetRemoval'));
|
||||||
}
|
}
|
||||||
else if (mission.getAttachedFromWaypoint(selectedMarker) && mission.getAttachedFromWaypoint(selectedMarker).length != 0) {
|
else if (mission.getAttachedFromWaypoint(selectedMarker) && mission.getAttachedFromWaypoint(selectedMarker).length != 0) {
|
||||||
if (confirm(i18n.getMessage('confirm_delete_point_with_options'))) {
|
if (confirm(i18n.getMessage('confirm_delete_point_with_options'))) {
|
||||||
|
@ -3096,7 +3096,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
|
|
||||||
$('#saveMissionButton').on('click', function () {
|
$('#saveMissionButton').on('click', function () {
|
||||||
if (mission.isEmpty()) {
|
if (mission.isEmpty()) {
|
||||||
alert(i18n.getMessage('no_waypoints_to_save'));
|
GUI.alert(i18n.getMessage('no_waypoints_to_save'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$(this).addClass('disabled');
|
$(this).addClass('disabled');
|
||||||
|
@ -3115,7 +3115,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
|
|
||||||
$('#saveEepromMissionButton').on('click', function () {
|
$('#saveEepromMissionButton').on('click', function () {
|
||||||
if (mission.isEmpty()) {
|
if (mission.isEmpty()) {
|
||||||
alert(i18n.getMessage('no_waypoints_to_save'));
|
GUI.alert(i18n.getMessage('no_waypoints_to_save'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$(this).addClass('disabled');
|
$(this).addClass('disabled');
|
||||||
|
@ -3445,7 +3445,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
$('#loadMissionButton').removeClass('disabled');
|
$('#loadMissionButton').removeClass('disabled');
|
||||||
}
|
}
|
||||||
if (!FC.MISSION_PLANNER.getCountBusyPoints()) {
|
if (!FC.MISSION_PLANNER.getCountBusyPoints()) {
|
||||||
alert(i18n.getMessage('no_waypoints_to_load'));
|
GUI.alert(i18n.getMessage('no_waypoints_to_load'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mission.reinit();
|
mission.reinit();
|
||||||
|
@ -3555,7 +3555,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
if (AbsAltCheck) {
|
if (AbsAltCheck) {
|
||||||
if (checkAltitude < 100 * elevation) {
|
if (checkAltitude < 100 * elevation) {
|
||||||
if (resetAltitude) {
|
if (resetAltitude) {
|
||||||
alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
GUI.alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||||
altitude = selectedMarker.getAlt();
|
altitude = selectedMarker.getAlt();
|
||||||
} else {
|
} else {
|
||||||
altitude = settings.alt + 100 * elevation;
|
altitude = settings.alt + 100 * elevation;
|
||||||
|
@ -3566,7 +3566,7 @@ TABS.mission_control.initialize = function (callback) {
|
||||||
let elevationAtHome = HOME.getAlt();
|
let elevationAtHome = HOME.getAlt();
|
||||||
if ((checkAltitude / 100 + elevationAtHome) < elevation) {
|
if ((checkAltitude / 100 + elevationAtHome) < elevation) {
|
||||||
if (resetAltitude) {
|
if (resetAltitude) {
|
||||||
alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
GUI.alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||||
altitude = selectedMarker.getAlt();
|
altitude = selectedMarker.getAlt();
|
||||||
} else {
|
} else {
|
||||||
let currentGroundClearance = 100 * Number($('#groundClearanceValueAtWP').text());
|
let currentGroundClearance = 100 * Number($('#groundClearanceValueAtWP').text());
|
||||||
|
@ -3702,9 +3702,9 @@ TABS.mission_control.setBit = function(bits, bit, value) {
|
||||||
|
|
||||||
// function handleError(evt) {
|
// function handleError(evt) {
|
||||||
// if (evt.message) { // Chrome sometimes provides this
|
// if (evt.message) { // Chrome sometimes provides this
|
||||||
// alert("error: "+evt.message +" at linenumber: "+evt.lineno+" of file: "+evt.filename);
|
// GUI.alert("error: "+evt.message +" at linenumber: "+evt.lineno+" of file: "+evt.filename);
|
||||||
// } else {
|
// } else {
|
||||||
// alert("error: "+evt.type+" from element: "+(evt.srcElement || evt.target));
|
// GUI.alert("error: "+evt.type+" from element: "+(evt.srcElement || evt.target));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ TABS.sitl.initialize = (callback) => {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (profiles.find(e => { return e.name == name })) {
|
if (profiles.find(e => { return e.name == name })) {
|
||||||
alert(i18n.getMessage('sitlProfileExists'))
|
GUI.alert(i18n.getMessage('sitlProfileExists'))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var eerpromName = name.replace(/[^a-z0-9]/gi, '_').toLowerCase() + ".bin";
|
var eerpromName = name.replace(/[^a-z0-9]/gi, '_').toLowerCase() + ".bin";
|
||||||
|
@ -284,7 +284,7 @@ TABS.sitl.initialize = (callback) => {
|
||||||
profileDeleteBtn_e.on('click', function () {
|
profileDeleteBtn_e.on('click', function () {
|
||||||
|
|
||||||
if (currentProfile.isStdProfile) {
|
if (currentProfile.isStdProfile) {
|
||||||
alert(i18n.getMessage('sitlStdProfileCantDeleted'));
|
GUI.alert(i18n.getMessage('sitlStdProfileCantDeleted'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ TABS.sitl.initialize = (callback) => {
|
||||||
|
|
||||||
function saveProfiles() {
|
function saveProfiles() {
|
||||||
if (currentProfile.isStdProfile) {
|
if (currentProfile.isStdProfile) {
|
||||||
alert(i18n.getMessage('sitlStdProfileCantOverwritten'));
|
GUI.alert(i18n.getMessage('sitlStdProfileCantOverwritten'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var profilesToSave = [];
|
var profilesToSave = [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue