diff --git a/electron_app/src/vectormenu.js b/electron_app/src/vectormenu.js index a8f998befc..b6e00d509d 100644 --- a/electron_app/src/vectormenu.js +++ b/electron_app/src/vectormenu.js @@ -40,6 +40,11 @@ const template = [ { role: 'zoomin', accelerator: 'CommandOrControl+=' }, { role: 'zoomout' }, { type: 'separator' }, + { + label: 'Preferences', + accelerator: 'Command+,', // Mac-only accelerator + click() { global.mainWindow.webContents.send('preferences'); }, + }, { role: 'togglefullscreen' }, { role: 'toggledevtools' }, ], diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 36f19a75a6..b77de12273 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -6,6 +6,7 @@ "Unexpected error preparing the app. See console for details.": "Unexpected error preparing the app. See console for details.", "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.", "Invalid configuration: no default server specified.": "Invalid configuration: no default server specified.", + "Open user settings": "Open user settings", "Riot Desktop on %(platformName)s": "Riot Desktop on %(platformName)s", "Go to your browser to complete Sign In": "Go to your browser to complete Sign In", "Unknown device": "Unknown device", diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index b6825bca04..5eff4f0fae 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -23,15 +23,29 @@ limitations under the License. import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform'; import BaseEventIndexManager from 'matrix-react-sdk/src/indexing/BaseEventIndexManager'; import dis from 'matrix-react-sdk/src/dispatcher'; -import { _t } from 'matrix-react-sdk/src/languageHandler'; +import { _t, _td } from 'matrix-react-sdk/src/languageHandler'; import * as rageshake from 'matrix-react-sdk/src/rageshake/rageshake'; import {MatrixClient} from "matrix-js-sdk"; import Modal from "matrix-react-sdk/src/Modal"; import InfoDialog from "matrix-react-sdk/src/components/views/dialogs/InfoDialog"; import Spinner from "matrix-react-sdk/src/components/views/elements/Spinner"; +import {Categories, Modifiers, registerShortcut} from "matrix-react-sdk/src/accessibility/KeyboardShortcuts"; +import {Key} from "matrix-react-sdk/src/Keyboard"; import React from "react"; const ipcRenderer = window.ipcRenderer; +const isMac = navigator.platform.toUpperCase().includes('MAC'); + +// register Mac specific shortcuts +if (isMac) { + registerShortcut(Categories.NAVIGATION, { + keybinds: [{ + modifiers: [Modifiers.COMMAND], + key: Key.COMMA, + }], + description: _td("Open user settings"), + }); +} function platformFriendlyName(): string { // used to use window.process but the same info is available here @@ -208,6 +222,10 @@ export default class ElectronPlatform extends VectorBasePlatform { ipcRenderer.on('ipcReply', this._onIpcReply.bind(this)); ipcRenderer.on('update-downloaded', this.onUpdateDownloaded.bind(this)); + ipcRenderer.on('preferences', () => { + dis.dispatch({ action: 'view_user_settings' }); + }); + this.startUpdateCheck = this.startUpdateCheck.bind(this); this.stopUpdateCheck = this.stopUpdateCheck.bind(this); } @@ -301,7 +319,7 @@ export default class ElectronPlatform extends VectorBasePlatform { supportsAutoHideMenuBar(): boolean { // This is irelevant on Mac as Menu bars don't live in the app window - return !navigator.platform.toUpperCase().includes('MAC'); + return !isMac; } async getAutoHideMenuBarEnabled(): boolean { @@ -314,7 +332,7 @@ export default class ElectronPlatform extends VectorBasePlatform { supportsMinimizeToTray(): boolean { // Things other than Mac support tray icons - return !navigator.platform.toUpperCase().includes('MAC'); + return !isMac; } async getMinimizeToTrayEnabled(): boolean {