mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 14:49:57 +02:00
refactor: Update ZenKeyboardShortcuts to toggle web panels and improve shortcuts
Remove unnecessary console.log statement in ZenThemeBuilder Disable Firefox shortcuts in ZenKeyboardShortcuts Initialize shortcuts only on the browser page Update ZenProfileDialogUI to improve profiles list and profile creation Remove unnecessary code in ZenWorkspaces.mjs Activate docShell for tab in ZenViewSplitter Remove redundant code in ZenViewSplitter
This commit is contained in:
parent
3f80eea589
commit
714a4428ef
4 changed files with 29 additions and 14 deletions
|
@ -15,6 +15,11 @@ const kZKSActions = {
|
||||||
showPreviousTab: ["gBrowser.tabContainer.advanceSelectedTab(-1, true)", "show-previous-tab", "tab-action"],
|
showPreviousTab: ["gBrowser.tabContainer.advanceSelectedTab(-1, true)", "show-previous-tab", "tab-action"],
|
||||||
showAllTabsPanel: ["gTabsPanel.showAllTabsPanel()", "show-all-tabs-panel", "tab-action"],
|
showAllTabsPanel: ["gTabsPanel.showAllTabsPanel()", "show-all-tabs-panel", "tab-action"],
|
||||||
|
|
||||||
|
// Compact mode actions
|
||||||
|
zenToggleCompactMode: ["gZenCompactModeManager.toggle()", "zen-toggle-compact-mode", "compact-mode-action"],
|
||||||
|
zenToggleCompactModeSidebar: ["gZenCompactModeManager.toggleSidebar()", "zen-toggle-compact-mode-sidebar", "compact-mode-action"],
|
||||||
|
zenToggleCompactModeToolbar: ["gZenCompactModeManager.toggleToolbar()", "zen-toggle-compact-mode-toolbar", "compact-mode-action"],
|
||||||
|
|
||||||
// Page actions
|
// Page actions
|
||||||
sendWithMail: ["command:Browser:SendLink", "send-with-mail", "page-action"],
|
sendWithMail: ["command:Browser:SendLink", "send-with-mail", "page-action"],
|
||||||
savePage: ["command:Browser:SavePage", "save-page", "page-action"],
|
savePage: ["command:Browser:SavePage", "save-page", "page-action"],
|
||||||
|
@ -132,7 +137,8 @@ var gZenKeyboardShortcuts = {
|
||||||
|
|
||||||
_initShortcuts() {
|
_initShortcuts() {
|
||||||
if (window.location.href == "chrome://browser/content/browser.xhtml") {
|
if (window.location.href == "chrome://browser/content/browser.xhtml") {
|
||||||
Services.prefs.addObserver(kZKSStorageKey, this._initSavedShortcuts.bind(this));
|
console.info("Zen CKS: Initializing shortcuts");
|
||||||
|
Services.prefs.addObserver(kZKSStorageKey, this._onShortcutChange.bind(this));
|
||||||
Services.prefs.addObserver("zen.keyboard.shortcuts.disable-firefox", this._disableFirefoxShortcuts.bind(this));
|
Services.prefs.addObserver("zen.keyboard.shortcuts.disable-firefox", this._disableFirefoxShortcuts.bind(this));
|
||||||
this._initSavedShortcuts();
|
this._initSavedShortcuts();
|
||||||
this._disableFirefoxShortcuts();
|
this._disableFirefoxShortcuts();
|
||||||
|
@ -141,18 +147,27 @@ var gZenKeyboardShortcuts = {
|
||||||
|
|
||||||
_disableFirefoxShortcuts() {
|
_disableFirefoxShortcuts() {
|
||||||
let disable = Services.prefs.getBoolPref("zen.keyboard.shortcuts.disable-firefox");
|
let disable = Services.prefs.getBoolPref("zen.keyboard.shortcuts.disable-firefox");
|
||||||
|
if (!disable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.SessionStore.promiseInitialized.then(() => {
|
||||||
let keySet = document.getElementById("mainKeyset");
|
let keySet = document.getElementById("mainKeyset");
|
||||||
if (!keySet) {
|
if (!keySet) {
|
||||||
throw new Error("Zen CKS: No main keyset found");
|
throw new Error("Zen CKS: No main keyset found");
|
||||||
}
|
}
|
||||||
if (disable) {
|
|
||||||
console.log("Zen CKS: Disabling Firefox shortcuts");
|
|
||||||
for (let child of keySet.children) {
|
for (let child of keySet.children) {
|
||||||
if (!child.id.startsWith("zen-key_")) {
|
if (!child.id.startsWith("zen-key_")) {
|
||||||
child.setAttribute("disabled", true);
|
child.setAttribute("disabled", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
console.info("Remove already exist shortcut keys");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_onShortcutChange() {
|
||||||
|
console.info("Zen CKS: Shortcut changed");
|
||||||
|
this.__savedShortcuts = null;
|
||||||
|
this._initSavedShortcuts();
|
||||||
},
|
},
|
||||||
|
|
||||||
_getCommandAttribute(action) {
|
_getCommandAttribute(action) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ var gZenThemeBuilder = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("gZenThemeBuilder: init builder UI");
|
console.info("gZenThemeBuilder: init builder UI");
|
||||||
|
|
||||||
const kTemplate = `
|
const kTemplate = `
|
||||||
<html:div id="zen-theme-builder">
|
<html:div id="zen-theme-builder">
|
||||||
|
|
|
@ -422,7 +422,7 @@ var gZenViewSplitter = new class {
|
||||||
// see browser-custom-elements.js's patch
|
// see browser-custom-elements.js's patch
|
||||||
tab.linkedBrowser.zenModeActive = active;
|
tab.linkedBrowser.zenModeActive = active;
|
||||||
try {
|
try {
|
||||||
console.log(tab.linkedBrowser);
|
console.info(tab.linkedBrowser);
|
||||||
tab.linkedBrowser.docShellIsActive = active;
|
tab.linkedBrowser.docShellIsActive = active;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
@ -8,9 +8,9 @@ var ZenWorkspaces = {
|
||||||
console.warn("ZenWorkspaces: !!! ZenWorkspaces is disabled in hidden windows !!!");
|
console.warn("ZenWorkspaces: !!! ZenWorkspaces is disabled in hidden windows !!!");
|
||||||
return; // We are in a hidden window, don't initialize ZenWorkspaces
|
return; // We are in a hidden window, don't initialize ZenWorkspaces
|
||||||
}
|
}
|
||||||
console.log("ZenWorkspaces: Initializing ZenWorkspaces...");
|
console.info("ZenWorkspaces: Initializing ZenWorkspaces...");
|
||||||
await this.initializeWorkspaces();
|
await this.initializeWorkspaces();
|
||||||
console.log("ZenWorkspaces: ZenWorkspaces initialized");
|
console.info("ZenWorkspaces: ZenWorkspaces initialized");
|
||||||
},
|
},
|
||||||
|
|
||||||
get workspaceEnabled() {
|
get workspaceEnabled() {
|
||||||
|
@ -100,14 +100,14 @@ var ZenWorkspaces = {
|
||||||
json.workspaces = [];
|
json.workspaces = [];
|
||||||
}
|
}
|
||||||
json.workspaces.push(workspaceData);
|
json.workspaces.push(workspaceData);
|
||||||
console.log("ZenWorkspaces: Saving workspace", workspaceData);
|
console.info("ZenWorkspaces: Saving workspace", workspaceData);
|
||||||
await IOUtils.writeJSON(this._storeFile, json);
|
await IOUtils.writeJSON(this._storeFile, json);
|
||||||
this._workspaceCache = null;
|
this._workspaceCache = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
async removeWorkspace(windowID) {
|
async removeWorkspace(windowID) {
|
||||||
let json = await this._workspaces();
|
let json = await this._workspaces();
|
||||||
console.log("ZenWorkspaces: Removing workspace", windowID);
|
console.info("ZenWorkspaces: Removing workspace", windowID);
|
||||||
await this.changeWorkspace(json.workspaces.find(workspace => workspace.uuid !== windowID));
|
await this.changeWorkspace(json.workspaces.find(workspace => workspace.uuid !== windowID));
|
||||||
this._deleteAllTabsInWorkspace(windowID);
|
this._deleteAllTabsInWorkspace(windowID);
|
||||||
json.workspaces = json.workspaces.filter(workspace => workspace.uuid !== windowID);
|
json.workspaces = json.workspaces.filter(workspace => workspace.uuid !== windowID);
|
||||||
|
@ -338,7 +338,7 @@ var ZenWorkspaces = {
|
||||||
workspace.used = workspace.uuid === window.uuid;
|
workspace.used = workspace.uuid === window.uuid;
|
||||||
}
|
}
|
||||||
this.unsafeSaveWorkspaces(workspaces);
|
this.unsafeSaveWorkspaces(workspaces);
|
||||||
console.log("ZenWorkspaces: Changing workspace to", window.uuid);
|
console.info("ZenWorkspaces: Changing workspace to", window.uuid);
|
||||||
for (let tab of gBrowser.tabs) {
|
for (let tab of gBrowser.tabs) {
|
||||||
if (tab.getAttribute("zen-workspace-id") === window.uuid && !tab.pinned) {
|
if (tab.getAttribute("zen-workspace-id") === window.uuid && !tab.pinned) {
|
||||||
if (!firstTab) {
|
if (!firstTab) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue