feat(hotkeys): Migrate hotkeys to customization service and fix issues with overrides (#4777)

This commit is contained in:
Alireza authored and GitHub committed 2025-02-25 13:32:30 -05:00
1 parent 4559d39a91
commit 3e6913b097
39 files changed
+814 -1552

No files matched your search

-1
View File
@@ -171,7 +171,6 @@ function modeFactory({ modeConfiguration }) {
dicompdf.sopClassHandler,
dicomsr.sopClassHandler,
],
hotkeys: [...hotkeys.defaults.hotkeyBindings],
};
}
+16 -1
View File
@@ -102,6 +102,22 @@ function modeFactory() {
'Crosshairs',
'MoreTools',
]);
customizationService.setCustomizations(
{
'ohif.hotkeyBindings': {
$push: [
{
commandName: 'undo',
label: 'Undo',
keys: ['ctrl+z'],
isEditable: true,
},
],
},
},
'mode'
);
},
onModeExit: ({ servicesManager }: withAppTypes) => {
const {
@@ -209,7 +225,6 @@ function modeFactory() {
// Don't store the hotkeys for basic-test-mode under the same key
// because they get customized by tests
name: 'basic-test-hotkeys',
hotkeys: [...hotkeys.defaults.hotkeyBindings],
},
};
}
+2 -2
View File
@@ -84,7 +84,8 @@ function modeFactory({ modeConfiguration }) {
* Lifecycle hooks
*/
onModeEnter: function ({ servicesManager, extensionManager, commandsManager }: withAppTypes) {
const { measurementService, toolbarService, toolGroupService } = servicesManager.services;
const { measurementService, toolbarService, toolGroupService, customizationService } =
servicesManager.services;
measurementService.clearMeasurements();
@@ -238,7 +239,6 @@ function modeFactory({ modeConfiguration }) {
dicomsr.sopClassHandler,
dicomRT.sopClassHandler,
],
hotkeys: [...hotkeys.defaults.hotkeyBindings],
...modeConfiguration,
};
}
+26
View File
@@ -205,6 +205,32 @@ const toolbarButtons: Button[] = [
},
},
},
// {
// id: 'Undo',
// uiType: 'ohif.toolButton',
// props: {
// type: 'tool',
// icon: 'prev-arrow',
// label: 'Undo',
// commands: {
// commandName: 'undo',
// },
// evaluate: 'evaluate.action',
// },
// },
// {
// id: 'Redo',
// uiType: 'ohif.toolButton',
// props: {
// type: 'tool',
// icon: 'next-arrow',
// label: 'Redo',
// commands: {
// commandName: 'redo',
// },
// evaluate: 'evaluate.action',
// },
// },
];
export default toolbarButtons;
-1
View File
@@ -123,7 +123,6 @@ function modeFactory({ modeConfiguration }) {
dicomvideo.sopClassHandler,
dicompdf.sopClassHandler,
],
hotkeys: [...hotkeys.defaults.hotkeyBindings],
...modeConfiguration,
};
}
-1
View File
@@ -167,7 +167,6 @@ function modeFactory({ modeConfiguration }) {
// general handler needs to come last. For this case, the dicomvideo must
// come first to remove video transfer syntax before ohif uses images
sopClassHandlers: [ohif.chartSopClassHandler, ohif.defaultSopClassHandler],
hotkeys: [...hotkeys.defaults.hotkeyBindings],
};
}
+2 -4
View File
@@ -1,4 +1,3 @@
import { hotkeys } from '@ohif/core';
import { id } from './id';
import toolbarButtons from './toolbarButtons';
import segmentationButtons from './segmentationButtons';
@@ -49,7 +48,8 @@ function modeFactory({ modeConfiguration }) {
* Services and other resources.
*/
onModeEnter: ({ servicesManager, extensionManager, commandsManager }: withAppTypes) => {
const { measurementService, toolbarService, toolGroupService } = servicesManager.services;
const { measurementService, toolbarService, toolGroupService, customizationService } =
servicesManager.services;
measurementService.clearMeasurements();
@@ -158,8 +158,6 @@ function modeFactory({ modeConfiguration }) {
// hangingProtocol: ['@ohif/mnGrid'],
/** SopClassHandlers used by the mode */
sopClassHandlers: [ohif.sopClassHandler, segmentation.sopClassHandler],
/** hotkeys for mode */
hotkeys: [...hotkeys.defaults.hotkeyBindings],
};
}
-1
View File
@@ -216,7 +216,6 @@ function modeFactory({ modeConfiguration }) {
extensions: extensionDependencies,
hangingProtocol: tmtv.hangingProtocol,
sopClassHandlers: [ohif.sopClassHandler],
hotkeys: [...hotkeys.defaults.hotkeyBindings],
...modeConfiguration,
};
}