瀏覽代碼

feat: Shortcut key for nerd stats (#3552)

* added alt+/ as the shortcut key for nerd stats

Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>

* added shortcut info in HelpDialog.ts

Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>

* resolved conflicts

Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>

* added shortcut info in HelpDialog.ts

Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
Gurkiran Singh 4 年之前
父節點
當前提交
bec34f2d57
共有 4 個文件被更改,包括 9 次插入1 次删除
  1. 3 0
      src/actions/actionToggleStats.tsx
  2. 1 1
      src/actions/shortcuts.ts
  3. 4 0
      src/components/HelpDialog.tsx
  4. 1 0
      src/keys.ts

+ 3 - 0
src/actions/actionToggleStats.tsx

@@ -1,4 +1,5 @@
 import { register } from "./register";
+import { CODES, KEYS } from "../keys";
 
 export const actionToggleStats = register({
   name: "stats",
@@ -13,4 +14,6 @@ export const actionToggleStats = register({
   },
   checked: (appState) => appState.showStats,
   contextItemLabel: "stats.title",
+  keyTest: (event) =>
+    !event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.SLASH,
 });

+ 1 - 1
src/actions/shortcuts.ts

@@ -57,7 +57,7 @@ const shortcutMap: Record<ShortcutName, string[]> = {
   ungroup: [getShortcutKey("CtrlOrCmd+Shift+G")],
   gridMode: [getShortcutKey("CtrlOrCmd+'")],
   zenMode: [getShortcutKey("Alt+Z")],
-  stats: [],
+  stats: [getShortcutKey("Alt+/")],
   addToLibrary: [],
   flipHorizontal: [getShortcutKey("Shift+H")],
   flipVertical: [getShortcutKey("Shift+V")],

+ 4 - 0
src/components/HelpDialog.tsx

@@ -235,6 +235,10 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
                   label={t("labels.toggleTheme")}
                   shortcuts={[getShortcutKey("Alt+Shift+D")]}
                 />
+                <Shortcut
+                  label={t("stats.title")}
+                  shortcuts={[getShortcutKey("Alt+/")]}
+                />
               </ShortcutIsland>
             </Column>
             <Column>

+ 1 - 0
src/keys.ts

@@ -14,6 +14,7 @@ export const CODES = {
   NINE: "Digit9",
   QUOTE: "Quote",
   ZERO: "Digit0",
+  SLASH: "Slash",
   C: "KeyC",
   D: "KeyD",
   G: "KeyG",