Bug 1188413 - Introduce key shortcut to reload tools r=past

This commit is contained in:
Alexandre Poirot 2015-09-29 03:06:25 -07:00
parent d49309d75c
commit 60a6a230de
4 changed files with 26 additions and 1 deletions

View File

@ -513,6 +513,11 @@ Toolbox.prototype = {
let toggleKey = this.doc.getElementById("toolbox-toggle-host-key");
toggleKey.addEventListener("command", this.switchToPreviousHost.bind(this), true);
if (Services.prefs.prefHasUserValue("devtools.loader.srcdir")) {
let reloadKey = this.doc.getElementById("tools-reload-key");
reloadKey.addEventListener("command", this.reload.bind(this), true);
}
// Split console uses keypress instead of command so the event can be
// cancelled with stopPropagation on the keypress, and not preventDefault.
this.doc.addEventListener("keypress", this._splitConsoleOnKeypress, false);
@ -1613,6 +1618,11 @@ Toolbox.prototype = {
return newHost;
},
reload: function () {
const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
devtools.reload(true);
},
/**
* Switch to the last used host for the toolbox UI.
* This is determined by the devtools.toolbox.previousHost pref.

View File

@ -95,6 +95,10 @@
key="&toolboxToggle.key;"
oncommand="void(0);"
modifiers="accel shift"/>
<key id="tools-reload-key"
key="&toolboxReload.key;"
oncommand="void(0);"
modifiers="accel alt"/>
</keyset>
<popupset>

View File

@ -70,6 +70,9 @@ var CommandUtils = {
* Utility to ensure that things are loaded in the correct order
*/
createRequisition: function(target, options) {
if (!gcliInit) {
return promise.reject("Unable to load gcli");
}
return gcliInit.getSystem(target).then(system => {
var Requisition = require("gcli/cli").Requisition;
return new Requisition(system, options);

View File

@ -423,7 +423,7 @@ DevToolsLoader.prototype = {
/**
* Reload the current provider.
*/
reload: function() {
reload: function(showToolbox) {
var events = this.require("sdk/system/events");
events.emit("startupcache-invalidate", {});
events.emit("devtools-unloaded", {});
@ -433,6 +433,14 @@ DevToolsLoader.prototype = {
delete this._mainid;
this._chooseProvider();
this.main("devtools/client/main");
// Reopen the toolbox automatically if requested
if (showToolbox) {
let { gBrowser } = Services.wm.getMostRecentWindow("navigator:browser");
let target = this.TargetFactory.forTab(gBrowser.selectedTab);
const { gDevTools } = this.require("resource:///modules/devtools/client/framework/gDevTools.jsm");
gDevTools.showToolbox(target);
}
},
/**