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',
|
||||
config: {
|
||||
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';
|
||||
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();
|
||||
|
||||
|
|
|
@ -53,6 +53,10 @@ function createDeviceChooser() {
|
|||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
createWindow();
|
||||
});
|
||||
|
||||
function createWindow() {
|
||||
|
||||
let mainWindowState = windowStateKeeper({
|
||||
defaultWidth: 800,
|
||||
|
@ -147,7 +151,7 @@ app.on('ready', () => {
|
|||
if (process.env.NODE_ENV === 'development') {
|
||||
mainWindow.webContents.openDevTools();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
|
||||
|
|
|
@ -483,7 +483,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
function checkApproachAltitude(altitude, isSeaLevelRef, sealevel) {
|
||||
|
||||
if (altitude - (isSeaLevelRef ? sealevel * 100 : 0 ) < 0) {
|
||||
alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
function checkLandingAltitude(altitude, isSeaLevelRef, sealevel) {
|
||||
|
||||
if (altitude - (isSeaLevelRef ? sealevel * 100 : 0 ) < MAX_NEG_FW_LAND_ALT) {
|
||||
alert(i18n.getMessage('MissionPlannerFwLAndingAltitudeChangeReset'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerFwLAndingAltitudeChangeReset'));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1489,26 +1489,26 @@ TABS.mission_control.initialize = function (callback) {
|
|||
if ($(this).val() >= 360 || ($(this).val() < 0 && $(this).val() != -1))
|
||||
{
|
||||
$(this).val(-1);
|
||||
alert(i18n.getMessage('MissionPlannerHeadSettingsCheck'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerHeadSettingsCheck'));
|
||||
}
|
||||
}
|
||||
else if (MWNP.WPTYPE.REV[element.getAction()] == "RTH") {
|
||||
if ($(this).val() != 0 && $(this).val() != 1)
|
||||
{
|
||||
$(this).val(0);
|
||||
alert(i18n.getMessage('MissionPlannerRTHSettingsCheck'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerRTHSettingsCheck'));
|
||||
}
|
||||
}
|
||||
else if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") {
|
||||
if ($(this).val() > mission.getNonAttachedList().length || $(this).val() < 1)
|
||||
{
|
||||
$(this).val(1);
|
||||
alert(i18n.getMessage('MissionPlannerJumpSettingsCheck'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerJumpSettingsCheck'));
|
||||
}
|
||||
else if (mission.getPoiList().length != 0 && mission.getPoiList()) {
|
||||
if (mission.getPoiList().includes(mission.convertJumpNumberToWaypoint(Number($(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))
|
||||
{
|
||||
$(this).val(0);
|
||||
alert(i18n.getMessage('MissionPlannerJump2SettingsCheck'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerJump2SettingsCheck'));
|
||||
}
|
||||
}
|
||||
element.setP2(Number($(this).val()));
|
||||
|
@ -2310,7 +2310,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
let found = false;
|
||||
mission.get().forEach(wp => {
|
||||
if (wp.getAction() == MWNP.WPTYPE.LAND) {
|
||||
alert(i18n.getMessage('MissionPlannerOnlyOneLandWp'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerOnlyOneLandWp'));
|
||||
found = true;
|
||||
$(event.currentTarget).val(selectedMarker.getAction());
|
||||
}
|
||||
|
@ -2684,7 +2684,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
|
||||
$('#addSafehome').on('click', () => {
|
||||
if (FC.SAFEHOMES.safehomeCount() + 1 > FC.SAFEHOMES.getMaxSafehomeCount()){
|
||||
alert(i18n.getMessage('missionSafehomeMaxSafehomesReached'));
|
||||
GUI.alert(i18n.getMessage('missionSafehomeMaxSafehomesReached'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3016,7 +3016,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
$('#removePoint').on('click', function () {
|
||||
if (selectedMarker) {
|
||||
if (mission.isJumpTargetAttached(selectedMarker)) {
|
||||
alert(i18n.getMessage('MissionPlannerJumpTargetRemoval'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerJumpTargetRemoval'));
|
||||
}
|
||||
else if (mission.getAttachedFromWaypoint(selectedMarker) && mission.getAttachedFromWaypoint(selectedMarker).length != 0) {
|
||||
if (confirm(i18n.getMessage('confirm_delete_point_with_options'))) {
|
||||
|
@ -3096,7 +3096,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
|
||||
$('#saveMissionButton').on('click', function () {
|
||||
if (mission.isEmpty()) {
|
||||
alert(i18n.getMessage('no_waypoints_to_save'));
|
||||
GUI.alert(i18n.getMessage('no_waypoints_to_save'));
|
||||
return;
|
||||
}
|
||||
$(this).addClass('disabled');
|
||||
|
@ -3115,7 +3115,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
|
||||
$('#saveEepromMissionButton').on('click', function () {
|
||||
if (mission.isEmpty()) {
|
||||
alert(i18n.getMessage('no_waypoints_to_save'));
|
||||
GUI.alert(i18n.getMessage('no_waypoints_to_save'));
|
||||
return;
|
||||
}
|
||||
$(this).addClass('disabled');
|
||||
|
@ -3445,7 +3445,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
$('#loadMissionButton').removeClass('disabled');
|
||||
}
|
||||
if (!FC.MISSION_PLANNER.getCountBusyPoints()) {
|
||||
alert(i18n.getMessage('no_waypoints_to_load'));
|
||||
GUI.alert(i18n.getMessage('no_waypoints_to_load'));
|
||||
return;
|
||||
}
|
||||
mission.reinit();
|
||||
|
@ -3555,7 +3555,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
if (AbsAltCheck) {
|
||||
if (checkAltitude < 100 * elevation) {
|
||||
if (resetAltitude) {
|
||||
alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||
altitude = selectedMarker.getAlt();
|
||||
} else {
|
||||
altitude = settings.alt + 100 * elevation;
|
||||
|
@ -3566,7 +3566,7 @@ TABS.mission_control.initialize = function (callback) {
|
|||
let elevationAtHome = HOME.getAlt();
|
||||
if ((checkAltitude / 100 + elevationAtHome) < elevation) {
|
||||
if (resetAltitude) {
|
||||
alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||
GUI.alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
|
||||
altitude = selectedMarker.getAlt();
|
||||
} else {
|
||||
let currentGroundClearance = 100 * Number($('#groundClearanceValueAtWP').text());
|
||||
|
@ -3702,9 +3702,9 @@ TABS.mission_control.setBit = function(bits, bit, value) {
|
|||
|
||||
// function handleError(evt) {
|
||||
// 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 {
|
||||
// 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;
|
||||
|
||||
if (profiles.find(e => { return e.name == name })) {
|
||||
alert(i18n.getMessage('sitlProfileExists'))
|
||||
GUI.alert(i18n.getMessage('sitlProfileExists'))
|
||||
return;
|
||||
}
|
||||
var eerpromName = name.replace(/[^a-z0-9]/gi, '_').toLowerCase() + ".bin";
|
||||
|
@ -284,7 +284,7 @@ TABS.sitl.initialize = (callback) => {
|
|||
profileDeleteBtn_e.on('click', function () {
|
||||
|
||||
if (currentProfile.isStdProfile) {
|
||||
alert(i18n.getMessage('sitlStdProfileCantDeleted'));
|
||||
GUI.alert(i18n.getMessage('sitlStdProfileCantDeleted'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ TABS.sitl.initialize = (callback) => {
|
|||
|
||||
function saveProfiles() {
|
||||
if (currentProfile.isStdProfile) {
|
||||
alert(i18n.getMessage('sitlStdProfileCantOverwritten'));
|
||||
GUI.alert(i18n.getMessage('sitlStdProfileCantOverwritten'));
|
||||
return;
|
||||
}
|
||||
var profilesToSave = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue