mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): restore global hotkeys
This commit is contained in:
parent
2bbab9d94e
commit
4a43e1c1b8
@ -8,6 +8,7 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
|||||||
import type { PartialAppConfig } from 'app/types/invokeai';
|
import type { PartialAppConfig } from 'app/types/invokeai';
|
||||||
import ImageUploader from 'common/components/ImageUploader';
|
import ImageUploader from 'common/components/ImageUploader';
|
||||||
import { useClearStorage } from 'common/hooks/useClearStorage';
|
import { useClearStorage } from 'common/hooks/useClearStorage';
|
||||||
|
import { useGlobalHotkeys } from 'common/hooks/useGlobalHotkeys';
|
||||||
import { useGlobalModifiersInit } from 'common/hooks/useGlobalModifiers';
|
import { useGlobalModifiersInit } from 'common/hooks/useGlobalModifiers';
|
||||||
import ChangeBoardModal from 'features/changeBoardModal/components/ChangeBoardModal';
|
import ChangeBoardModal from 'features/changeBoardModal/components/ChangeBoardModal';
|
||||||
import DeleteImageModal from 'features/deleteImageModal/components/DeleteImageModal';
|
import DeleteImageModal from 'features/deleteImageModal/components/DeleteImageModal';
|
||||||
@ -44,6 +45,7 @@ const App = ({ config = DEFAULT_CONFIG, selectedImage }: Props) => {
|
|||||||
// singleton!
|
// singleton!
|
||||||
useSocketIO();
|
useSocketIO();
|
||||||
useGlobalModifiersInit();
|
useGlobalModifiersInit();
|
||||||
|
useGlobalHotkeys();
|
||||||
|
|
||||||
const handleReset = useCallback(() => {
|
const handleReset = useCallback(() => {
|
||||||
clearStorage();
|
clearStorage();
|
||||||
|
95
invokeai/frontend/web/src/common/hooks/useGlobalHotkeys.ts
Normal file
95
invokeai/frontend/web/src/common/hooks/useGlobalHotkeys.ts
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
|
import { useQueueBack } from 'features/queue/hooks/useQueueBack';
|
||||||
|
import { useQueueFront } from 'features/queue/hooks/useQueueFront';
|
||||||
|
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
|
||||||
|
import { setActiveTab } from 'features/ui/store/uiSlice';
|
||||||
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
|
|
||||||
|
export const useGlobalHotkeys = () => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const isModelManagerEnabled =
|
||||||
|
useFeatureStatus('modelManager').isFeatureEnabled;
|
||||||
|
const {
|
||||||
|
queueBack,
|
||||||
|
isDisabled: isDisabledQueueBack,
|
||||||
|
isLoading: isLoadingQueueBack,
|
||||||
|
} = useQueueBack();
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
['ctrl+enter', 'meta+enter'],
|
||||||
|
queueBack,
|
||||||
|
{
|
||||||
|
enabled: () => !isDisabledQueueBack && !isLoadingQueueBack,
|
||||||
|
preventDefault: true,
|
||||||
|
enableOnFormTags: ['input', 'textarea', 'select'],
|
||||||
|
},
|
||||||
|
[queueBack, isDisabledQueueBack, isLoadingQueueBack]
|
||||||
|
);
|
||||||
|
|
||||||
|
const {
|
||||||
|
queueFront,
|
||||||
|
isDisabled: isDisabledQueueFront,
|
||||||
|
isLoading: isLoadingQueueFront,
|
||||||
|
} = useQueueFront();
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
['ctrl+shift+enter', 'meta+shift+enter'],
|
||||||
|
queueFront,
|
||||||
|
{
|
||||||
|
enabled: () => !isDisabledQueueFront && !isLoadingQueueFront,
|
||||||
|
preventDefault: true,
|
||||||
|
enableOnFormTags: ['input', 'textarea', 'select'],
|
||||||
|
},
|
||||||
|
[queueFront, isDisabledQueueFront, isLoadingQueueFront]
|
||||||
|
);
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
'1',
|
||||||
|
() => {
|
||||||
|
dispatch(setActiveTab('txt2img'));
|
||||||
|
},
|
||||||
|
[dispatch]
|
||||||
|
);
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
'2',
|
||||||
|
() => {
|
||||||
|
dispatch(setActiveTab('img2img'));
|
||||||
|
},
|
||||||
|
[dispatch]
|
||||||
|
);
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
'3',
|
||||||
|
() => {
|
||||||
|
dispatch(setActiveTab('unifiedCanvas'));
|
||||||
|
},
|
||||||
|
[dispatch]
|
||||||
|
);
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
'4',
|
||||||
|
() => {
|
||||||
|
dispatch(setActiveTab('nodes'));
|
||||||
|
},
|
||||||
|
[dispatch]
|
||||||
|
);
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
'5',
|
||||||
|
() => {
|
||||||
|
if (isModelManagerEnabled) {
|
||||||
|
dispatch(setActiveTab('modelManager'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[dispatch, isModelManagerEnabled]
|
||||||
|
);
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
isModelManagerEnabled ? '6' : '5',
|
||||||
|
() => {
|
||||||
|
dispatch(setActiveTab('queue'));
|
||||||
|
},
|
||||||
|
[dispatch, isModelManagerEnabled]
|
||||||
|
);
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user