macOS: Move Window → Zotero to platformKeys (#4778)
And change shortcut to Cmd-Shift-L to avoid conflicts with various font size and zoom shortcuts.
This commit is contained in:
parent
5d0420a7d0
commit
8c5a863aaf
3 changed files with 50 additions and 17 deletions
|
@ -3,7 +3,9 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Don't need to depend on Zotero object here
|
||||
const { AppConstants } = ChromeUtils.importESModule('resource://gre/modules/AppConstants.sys.mjs');
|
||||
|
||||
// Can't depend on Zotero object in hidden window initialization
|
||||
let isWin = AppConstants.platform == 'win';
|
||||
let isMac = AppConstants.platform == 'macosx';
|
||||
|
||||
|
@ -20,6 +22,11 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||
let applicationMenu = document.getElementById('mac_application_menu');
|
||||
let windowMenu = document.getElementById('windowMenu');
|
||||
let macKeyset = document.getElementById('macKeyset');
|
||||
|
||||
let genericCommandSet = document.createXULElement('commandset');
|
||||
document.documentElement.append(genericCommandSet);
|
||||
let genericKeyset = document.createXULElement('keyset');
|
||||
document.documentElement.append(genericKeyset);
|
||||
|
||||
if (isWin) {
|
||||
// Set behavior on Windows only
|
||||
|
@ -44,6 +51,42 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||
if (fileQuitItemUnix) fileQuitItemUnix.hidden = true;
|
||||
if (editPreferencesSeparator) editPreferencesSeparator.hidden = true;
|
||||
if (editPreferencesItem) editPreferencesItem.hidden = true;
|
||||
|
||||
// Non-main windows: Add Window → Zotero to focus/reopen main window
|
||||
if (windowMenu && window.location.href !== AppConstants.BROWSER_CHROME_URL) {
|
||||
MozXULElement.insertFTLIfNeeded('branding/brand.ftl');
|
||||
MozXULElement.insertFTLIfNeeded('zotero.ftl');
|
||||
|
||||
let mainWindowCommand = document.createXULElement('command');
|
||||
mainWindowCommand.id = 'cmd_mainWindow';
|
||||
document.l10n.setAttributes(mainWindowCommand, 'main-window-command');
|
||||
mainWindowCommand.addEventListener('command', () => {
|
||||
// Zotero.getMainWindow()
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
if (win) {
|
||||
win.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Zotero.openMainWindow()
|
||||
var chromeURI = AppConstants.BROWSER_CHROME_URL;
|
||||
var flags = "chrome,all,dialog=no,resizable=yes";
|
||||
Services.ww.openWindow(null, chromeURI, '_blank', flags, null);
|
||||
});
|
||||
genericCommandSet.append(mainWindowCommand);
|
||||
|
||||
let mainWindowKey = document.createXULElement('key');
|
||||
mainWindowKey.id = 'key_mainWindow';
|
||||
mainWindowKey.setAttribute('command', mainWindowCommand.id);
|
||||
mainWindowKey.setAttribute('modifiers', 'accel shift');
|
||||
document.l10n.setAttributes(mainWindowKey, 'main-window-key');
|
||||
genericKeyset.append(mainWindowKey);
|
||||
|
||||
let mainWindowItem = document.createXULElement('menuitem');
|
||||
mainWindowItem.setAttribute('command', mainWindowCommand.id);
|
||||
mainWindowItem.setAttribute('key', mainWindowKey.id);
|
||||
windowMenu.menupopup.append(mainWindowItem);
|
||||
}
|
||||
|
||||
// macOS 15 Sequoia has a new system keyboard shortcut, Ctrl-Return,
|
||||
// that shows a context menu on the focused control. Firefox currently
|
||||
|
|
|
@ -42,20 +42,11 @@
|
|||
<html:link rel="localization" href="browser/browserSets.ftl"/>
|
||||
|
||||
<script type="application/javascript">
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
||||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/globalOverlay.js", this);
|
||||
Services.scriptloader.loadSubScript("chrome://zotero/content/platformKeys.js", this);
|
||||
</script>
|
||||
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script>
|
||||
// Equivalent to Zotero.openMainWindow()
|
||||
function openMainWindow() {
|
||||
var chromeURI = AppConstants.BROWSER_CHROME_URL;
|
||||
var flags = "chrome,all,dialog=no,resizable=yes";
|
||||
var ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
|
||||
.getService(Components.interfaces.nsIWindowWatcher);
|
||||
ww.openWindow(null, chromeURI, '_blank', flags, null);
|
||||
}
|
||||
|
||||
function openAbout() {
|
||||
var ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
|
||||
.getService(Components.interfaces.nsIWindowWatcher);
|
||||
|
@ -84,12 +75,10 @@
|
|||
<command id="cmd_close" disabled="true"/>
|
||||
<command id="minimizeWindow" disabled="true" data-l10n-id="window-minimize-command"/>
|
||||
<command id="zoomWindow" disabled="true" data-l10n-id="window-zoom-command"/>
|
||||
<command id="cmd_mainWindow" data-l10n-id="main-window-command" oncommand="openMainWindow();"/>
|
||||
</commandset>
|
||||
|
||||
<keyset id="mainKeyset">
|
||||
<key id="key_close" data-l10n-id="close-shortcut" command="cmd_close" modifiers="accel"/>
|
||||
<key id="key_mainWindow" key="0" command="cmd_mainWindow" modifiers="accel"/>
|
||||
<key id="key_preferencesCmdMac"
|
||||
data-l10n-id="preferences-shortcut"
|
||||
modifiers="accel"
|
||||
|
@ -158,7 +147,6 @@
|
|||
<menuseparator/>
|
||||
<menuitem label="&bringAllToFront.label;" disabled="true"/> -->
|
||||
<menuseparator id="sep-window-list"/>
|
||||
<menuitem command="cmd_mainWindow" key="key_mainWindow"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menubar>
|
||||
|
|
|
@ -82,7 +82,9 @@ menu-view-columns-move-right =
|
|||
.label = Move Column Right
|
||||
|
||||
main-window-command =
|
||||
.label = { -app-name }
|
||||
.label = Library
|
||||
main-window-key =
|
||||
.key = L
|
||||
|
||||
zotero-toolbar-tabs-menu =
|
||||
.tooltiptext = List all tabs
|
||||
|
|
Loading…
Reference in a new issue