Option to automatically open DevTools (#3352)

master
Károly Kiripolszky 2023-03-02 18:29:24 +01:00 committed by GitHub
parent 7f3ba27301
commit 6abcce226f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 0 deletions

View File

@ -6822,5 +6822,9 @@
}, },
"coreBuildModeDescription": { "coreBuildModeDescription": {
"message": "This option builds a firmware that contains the hardware drivers (and some limited features). It is available to assist in the detection of the hardware on a flight controller, and is provided for that convenience only. Not all features will be available (only hardware) using this option." "message": "This option builds a firmware that contains the hardware drivers (and some limited features). It is available to assist in the detection of the hardware on a flight controller, and is provided for that convenience only. Not all features will be available (only hardware) using this option."
},
"showDevToolsOnStartup": {
"message": "Automatically open DevTools in development mode",
"description": "Text for the option to enable automatic opening of DevTools in debug mode"
} }
} }

View File

@ -35,6 +35,10 @@ const CONFIGURATOR = {
return `${this.version}`; return `${this.version}`;
} }
}, },
isDevVersion: function() {
return this.version.includes('debug');
},
}; };
export default CONFIGURATOR; export default CONFIGURATOR;

View File

@ -183,6 +183,10 @@ function startProcess() {
GUI.nwGui.Shell.openExternal(url); GUI.nwGui.Shell.openExternal(url);
}); });
nwWindow.on('close', closeHandler); nwWindow.on('close', closeHandler);
const config = getConfig('showDevToolsOnStartup');
if (CONFIGURATOR.isDevVersion() && !!config.showDevToolsOnStartup) {
nwWindow.showDevTools();
}
} else if (GUI.isCordova()) { } else if (GUI.isCordova()) {
window.addEventListener('beforeunload', closeHandler); window.addEventListener('beforeunload', closeHandler);
document.addEventListener('backbutton', function(e) { document.addEventListener('backbutton', function(e) {

View File

@ -6,6 +6,7 @@ import CliAutoComplete from '../CliAutoComplete';
import DarkTheme, { setDarkTheme } from '../DarkTheme'; import DarkTheme, { setDarkTheme } from '../DarkTheme';
import { checkForConfiguratorUpdates } from '../utils/checkForConfiguratorUpdates'; import { checkForConfiguratorUpdates } from '../utils/checkForConfiguratorUpdates';
import { checkSetupAnalytics } from '../Analytics'; import { checkSetupAnalytics } from '../Analytics';
import CONFIGURATOR from '../data_storage';
const options = {}; const options = {};
options.initialize = function (callback) { options.initialize = function (callback) {
@ -25,6 +26,7 @@ options.initialize = function (callback) {
TABS.options.initShowVirtualMode(); TABS.options.initShowVirtualMode();
TABS.options.initCordovaForceComputerUI(); TABS.options.initCordovaForceComputerUI();
TABS.options.initDarkTheme(); TABS.options.initDarkTheme();
TABS.options.initShowDevToolsOnStartup();
TABS.options.initShowWarnings(); TABS.options.initShowWarnings();
@ -185,6 +187,18 @@ options.initDarkTheme = function () {
}).change(); }).change();
}; };
options.initShowDevToolsOnStartup = function () {
if (!(CONFIGURATOR.isDevVersion() && GUI.isNWJS())) {
$('div.showDevToolsOnStartup').hide();
return;
}
const result = getConfig('showDevToolsOnStartup');
$('div.showDevToolsOnStartup input')
.prop('checked', !!result.showDevToolsOnStartup)
.change(function () { setConfig({ showDevToolsOnStartup: $(this).is(':checked') }); })
.change();
};
// TODO: remove when modules are in place // TODO: remove when modules are in place
TABS.options = options; TABS.options = options;
export { options }; export { options };

View File

@ -61,6 +61,12 @@
</select> </select>
<span class="freelabel" i18n="darkTheme"></span> <span class="freelabel" i18n="darkTheme"></span>
</div> </div>
<div class="showDevToolsOnStartup margin-bottom">
<div>
<input type="checkbox" class="toggle" />
</div>
<span class="freelabel" i18n="showDevToolsOnStartup"></span>
</div>
</div> </div>
</div> </div>