Allow customize keyboard shortcuts for toggling pin tab (#10301)

Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Co-authored-by: mr. m <91018726+mr-cheffy@users.noreply.github.com>
This commit is contained in:
Yukai Huang
2025-09-12 00:29:57 +08:00
committed by GitHub
parent 09b6a095e4
commit ed6ea91528
4 changed files with 34 additions and 2 deletions

View File

@@ -259,6 +259,7 @@ zen-key-exit-full-screen = Exit Full Screen
zen-ai-chatbot-sidebar-shortcut = Toggle AI Chatbot Sidebar
zen-key-inspector-mac = Toggle Inspector (Mac)
zen-toggle-sidebar-shortcut = Toggle Firefox Sidebar
zen-toggle-pin-tab-shortcut = Toggle Pin Tab
zen-reader-mode-toggle-shortcut-other = Toggle Reader Mode
zen-picture-in-picture-toggle-shortcut = Toggle Picture-in-Picture
zen-nav-reload-shortcut-2 = Reload Page

View File

@@ -59,4 +59,6 @@
<command id="cmd_zenGlanceSplit" />
<command id="cmd_zenOpenFolderCreation" />
<command id="cmd_zenTogglePinTab" />
</commandset>

View File

@@ -115,6 +115,16 @@ document.addEventListener(
renameFolder: true,
});
break;
case 'cmd_zenTogglePinTab':
const currentTab = gBrowser.selectedTab;
if (currentTab) {
if (currentTab.pinned) {
gBrowser.unpinTab(currentTab);
} else {
gBrowser.pinTab(currentTab);
}
}
break;
default:
gZenGlanceManager.handleMainCommandSet(event);
if (event.target.id.startsWith('cmd_zenWorkspaceSwitch')) {

View File

@@ -843,7 +843,13 @@ class nsZenKeyboardShortcutsVersioner {
// Hard-remove deprecated or conflicting defaults regardless of version
// - Remove the built-in "Open File" keybinding; menu item remains available
out = out.filter((shortcut) => shortcut.getAction?.() !== 'Browser:OpenFile');
// - Remove default "Bookmark All Tabs" keybinding (Ctrl+Shift+D) to avoid conflict
out = out.filter(
(shortcut) =>
shortcut.getAction?.() !== 'Browser:OpenFile' &&
shortcut.getAction?.() !== 'Browser:BookmarkAllTabs' &&
shortcut.getAction?.() !== 'key_stop'
);
return out;
}
@@ -1002,7 +1008,20 @@ class nsZenKeyboardShortcutsVersioner {
}
if (version < 10) {
// Migrate from version 9 to 10
// 1) Add shortcut to expand Glance into a full tab: Default Accel+O
// 1) Add the new pin/unpin tab toggle shortcut with Ctrl+Shift+D
data.push(
new KeyShortcut(
'zen-toggle-pin-tab',
'D',
'',
ZEN_OTHER_SHORTCUTS_GROUP,
nsKeyShortcutModifiers.fromObject({ accel: true, shift: true }),
'cmd_zenTogglePinTab',
'zen-toggle-pin-tab-shortcut'
)
);
// 2) Add shortcut to expand Glance into a full tab: Default Accel+O
data.push(
new KeyShortcut(
'zen-glance-expand',