From c208cec5384e3682a9ac45fcc94cc031ace067e0 Mon Sep 17 00:00:00 2001 From: Kirill Shumilov Date: Fri, 20 Nov 2020 15:51:40 +0300 Subject: [PATCH] feat(xod-client, xod-client-browser, xod-client-electron): add hotkeys for upload popup and change one for the debugger pane --- packages/xod-client-browser/src/containers/App.jsx | 4 ++++ .../xod-client-electron/src/view/containers/App.jsx | 8 +++++++- packages/xod-client/src/utils/constants.js | 12 ++++++++++-- packages/xod-client/src/utils/menu.js | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/xod-client-browser/src/containers/App.jsx b/packages/xod-client-browser/src/containers/App.jsx index a1dab9969..7c782d545 100644 --- a/packages/xod-client-browser/src/containers/App.jsx +++ b/packages/xod-client-browser/src/containers/App.jsx @@ -52,6 +52,10 @@ class App extends client.App { { [client.COMMAND.NEW_PROJECT]: this.onCreateProject, [client.COMMAND.ADD_PATCH]: this.props.actions.createPatch, + [client.COMMAND.TOGGLE_DEBUGGER]: e => { + e.preventDefault(); + this.props.actions.toggleDebugger(); + }, }, this.defaultHotkeyHandlers ); diff --git a/packages/xod-client-electron/src/view/containers/App.jsx b/packages/xod-client-electron/src/view/containers/App.jsx index 5b5b46117..6b13c8a1f 100644 --- a/packages/xod-client-electron/src/view/containers/App.jsx +++ b/packages/xod-client-electron/src/view/containers/App.jsx @@ -191,7 +191,13 @@ class App extends client.App { this.showError(error); }); - this.hotkeyHandlers = this.defaultHotkeyHandlers; + this.hotkeyHandlers = R.merge( + { + [client.COMMAND.UPLOAD_WITH_DEBUG]: this + .onUploadToArduinoAndDebugClicked, + }, + this.defaultHotkeyHandlers + ); this.urlActions = { // actionPathName: params => this.props.actions.someAction(params.foo, params.bar), diff --git a/packages/xod-client/src/utils/constants.js b/packages/xod-client/src/utils/constants.js index 22c9363d8..8fd7160c5 100644 --- a/packages/xod-client/src/utils/constants.js +++ b/packages/xod-client/src/utils/constants.js @@ -35,6 +35,9 @@ export const COMMAND = { MAKE_TERMINAL: 'makeTerminal', MAKE_CONSTANT: 'makeConstant', MAKE_INTERACTIVE: 'makeInteractive', + + UPLOAD: 'upload', + UPLOAD_WITH_DEBUG: 'uploadWithDebug', }; export const HOTKEY = { @@ -58,7 +61,7 @@ export const HOTKEY = { [COMMAND.HIDE_HELPBOX]: 'escape', [COMMAND.TOGGLE_HELP]: ['h'], - [COMMAND.TOGGLE_DEBUGGER]: ['ctrl+shift+u'], + [COMMAND.TOGGLE_DEBUGGER]: 'CmdOrCtrl+d', [COMMAND.INSERT_NODE]: ['i'], [COMMAND.MAKE_BUS]: ['b'], @@ -68,6 +71,8 @@ export const HOTKEY = { [COMMAND.PAN_TO_ORIGIN]: ['home'], [COMMAND.PAN_TO_CENTER]: 'CmdOrCtrl+home', + + [COMMAND.UPLOAD_WITH_DEBUG]: 'CmdOrCtrl+shift+u', }; export const ELECTRON_ACCELERATOR = { @@ -92,10 +97,13 @@ export const ELECTRON_ACCELERATOR = { [COMMAND.SAVE_COPY_AS]: 'CmdOrCtrl+Shift+Alt+S', [COMMAND.HIDE_HELPBOX]: 'Escape', - [COMMAND.TOGGLE_DEBUGGER]: 'CmdOrCtrl+Shift+U', + [COMMAND.TOGGLE_DEBUGGER]: 'CmdOrCtrl+D', [COMMAND.PAN_TO_ORIGIN]: 'Home', [COMMAND.PAN_TO_CENTER]: 'CmdOrCtrl+Home', + + [COMMAND.UPLOAD]: 'CmdOrCtrl+u', + [COMMAND.UPLOAD_WITH_DEBUG]: 'CmdOrCtrl+shift+u', }; export const KEYCODE = { diff --git a/packages/xod-client/src/utils/menu.js b/packages/xod-client/src/utils/menu.js index e26ff8dae..8911c8525 100644 --- a/packages/xod-client/src/utils/menu.js +++ b/packages/xod-client/src/utils/menu.js @@ -108,6 +108,7 @@ const rawItems = { }, uploadToArduino: { label: 'Upload to Arduino...', + command: COMMAND.UPLOAD, }, connectSerial: { label: 'Connect Serial...',