From 49fe19508934a7c1bfeb2051c49342603dece353 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 5 Jun 2019 21:29:50 -0400 Subject: [PATCH] Change HotkeyDefinition to include label --- public/config/default.js | 74 +++++++++++++++++++++++----------------- src/App.js | 13 ++----- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/public/config/default.js b/public/config/default.js index c53ad9274..c9e2bd5ab 100644 --- a/public/config/default.js +++ b/public/config/default.js @@ -19,44 +19,56 @@ window.config = { }, ], }, - // - userPreferences: [ - { - order: 0, - title: 'preference page title', - items: [ - { - order: 0, - label: 'Scale Viewport Up', - command: 'scaleUpViewport', - }, - ], - }, - ], - // - hotkeys: { + /** + * This maps registered commands to default hotkey values. + */ + hotkeys: [ // ~ Global - incrementActiveViewport: ['right'], - decrementActiveViewport: ['left'], + { + commandName: 'incrementActiveViewport', + label: 'Next Image Viewport', + keys: ['right'], + }, + { + commandName: 'decrementActiveViewport', + label: 'Previous Image Viewport', + keys: ['left'], + }, // Supported Keys: https://craig.is/killing/mice // ~ Cornerstone Extension - rotateViewportCW: ['r'], - rotateViewportCCW: ['l'], - invertViewport: ['i'], - flipViewportVertical: ['h'], - flipViewportHorizontal: ['v'], - scaleUpViewport: ['+'], - scaleDownViewport: ['-'], - fitViewportToWindow: ['='], - resetViewport: ['space'], + { commandName: 'rotateViewportCW', label: 'Rotate Right', keys: ['r'] }, + { commandName: 'rotateViewportCCW', label: 'Rotate Left', keys: ['l'] }, + { commandName: 'invertViewport', label: 'Invert', keys: ['i'] }, + { + commandName: 'flipViewportVertical', + label: 'Flip Horizontally', + keys: ['h'], + }, + { + commandName: 'flipViewportHorizontal', + label: 'Flip Vertically', + keys: ['v'], + }, + { commandName: 'scaleUpViewport', label: 'Zoom In', keys: ['+'] }, + { commandName: 'scaleDownViewport', label: 'Zoom Out', keys: ['-'] }, + { commandName: 'fitViewportToWindow', label: 'Zoom to Fit', keys: ['='] }, + { commandName: 'resetViewport', label: 'Reset', keys: ['space'] }, // clearAnnotations // nextImage // previousImage // firstImage // lastImage - nextViewportDisplaySet: ['pageup'], - previousViewportDisplaySet: ['pagedown'], + { + commandName: 'nextViewportDisplaySet', + label: 'Previous Series', + keys: ['pagedown'], + }, + { + commandName: 'previousViewportDisplaySet', + label: 'Next Series', + keys: ['pageup'], + }, // ~ Cornerstone Tools - setZoomTool: ['z'], - }, + { commandName: 'setZoomTool', label: 'Zoom', keys: ['z'] }, + ], }; diff --git a/src/App.js b/src/App.js index 3273ba325..895d69192 100644 --- a/src/App.js +++ b/src/App.js @@ -40,16 +40,9 @@ const _commandsManager = new CommandsManager(commandsManagerConfig); const _hotkeysManager = new HotkeysManager(_commandsManager); // TODO: Should be done in extensions w/ commandsModule -// ADD COMMANDS +// ~~ ADD COMMANDS appCommands.init(_commandsManager); - -// window.config.userPreferences -Object.keys(window.config.hotkeys).forEach(commandName => { - const keys = window.config.hotkeys[commandName]; - // HotkeysManager.set(); - console.log(`registering hotkey: ${commandName} to binding: ${keys}`); - _hotkeysManager.registerHotkeys(commandName, keys); -}); +_hotkeysManager.setHotkeys(window.config.hotkeys, true); // Force active contexts for now. These should be set in Viewer/ActiveViewer store.dispatch({ @@ -61,7 +54,7 @@ store.dispatch({ item: 'VIEWER::CORNERSTONE', }); -// ~~~~ END EPP SETUP +// ~~~~ END APP SETUP setupTools(store);