From 622e8dc3e06e99d3cba83766e2e4d92c3189ec7f Mon Sep 17 00:00:00 2001 From: V Date: Thu, 11 May 2023 19:00:18 +0200 Subject: [PATCH] [skip ci] Translate: Shift/Right click shortcut --- src/plugins/translate/TranslateIcon.tsx | 11 ++++++++--- src/plugins/translate/settings.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/translate/TranslateIcon.tsx b/src/plugins/translate/TranslateIcon.tsx index af97a53b..bdec1276 100644 --- a/src/plugins/translate/TranslateIcon.tsx +++ b/src/plugins/translate/TranslateIcon.tsx @@ -43,6 +43,8 @@ export function TranslateChatBarIcon({ slateProps }: { slateProps: { type: { ana if (slateProps.type.analyticsName !== "normal") return null; + const toggle = () => settings.store.autoTranslate = !autoTranslate; + return ( {({ onMouseEnter, onMouseLeave }) => ( @@ -55,11 +57,14 @@ export function TranslateChatBarIcon({ slateProps }: { slateProps: { type: { ana onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} innerClassName={ButtonWrapperClasses.button} - onClick={() => + onClick={e => { + if (e.shiftKey) return toggle(); + openModal(props => ( - )) - } + )); + }} + onContextMenu={() => toggle()} style={{ padding: "0 4px" }} >
diff --git a/src/plugins/translate/settings.ts b/src/plugins/translate/settings.ts index 13e6540a..aa4f633a 100644 --- a/src/plugins/translate/settings.ts +++ b/src/plugins/translate/settings.ts @@ -46,7 +46,7 @@ export const settings = definePluginSettings({ }, autoTranslate: { type: OptionType.BOOLEAN, - description: "Automatically translate your messages before sending", + description: "Automatically translate your messages before sending. You can also shift/right click the translate button to toggle this", default: false } });