From fdfe49574f9b8e5f9d88b35a0dae655268a2360e Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:20:08 -0800 Subject: [PATCH 01/14] fix: default value in short cut --- .../Configuration+Defaults.swift | 46 ++++++++----------- .../Feature/Shortcut/Shortcut+Default.swift | 21 --------- .../NewApp/Feature/Shortcut/Shortcut.swift | 8 ---- 3 files changed, 20 insertions(+), 55 deletions(-) diff --git a/Easydict/NewApp/Configuration/Configuration+Defaults.swift b/Easydict/NewApp/Configuration/Configuration+Defaults.swift index 240aed001..ea4839965 100644 --- a/Easydict/NewApp/Configuration/Configuration+Defaults.swift +++ b/Easydict/NewApp/Configuration/Configuration+Defaults.swift @@ -10,12 +10,6 @@ import Defaults import Foundation import Magnet -/// Utils -extension Defaults.Keys { - /// is first launch - static let firstLaunch = Key("EZConfiguration_kFirstLaunch", default: true) -} - // Setting extension Defaults.Keys { // rename `from` @@ -178,26 +172,26 @@ extension Defaults.Keys { /// shortcut extension Defaults.Keys { // Global - static let selectionShortcut = Key("EZSelectionShortcutKey_keyHolder") - static let snipShortcut = Key("EZSnipShortcutKey_keyHolder") - static let inputShortcut = Key("EZInputShortcutKey_keyHolder") - static let screenshotOCRShortcut = Key("EZScreenshotOCRShortcutKey_keyHolder") - static let showMiniWindowShortcut = Key("EZShowMiniShortcutKey_keyHolder") + static let selectionShortcut = Key("EZSelectionShortcutKey_keyHolder", default: KeyCombo(key: .d, cocoaModifiers: .option)) + static let snipShortcut = Key("EZSnipShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .option)) + static let inputShortcut = Key("EZInputShortcutKey_keyHolder", default: KeyCombo(key: .a, cocoaModifiers: .option)) + static let screenshotOCRShortcut = Key("EZScreenshotOCRShortcutKey_keyHolder", default: KeyCombo(key: .f, cocoaModifiers: [.option, .shift])) + static let showMiniWindowShortcut = Key("EZShowMiniShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .option)) // App - static let clearInputShortcut = Key("EZClearInputShortcutKey_keyHolder") - static let clearAllShortcut = Key("EZClearAllShortcutKey_keyHolder") - static let copyShortcut = Key("EZCopyShortcutKey_keyHolder") - static let copyFirstResultShortcut = Key("EZCopyFirstResultShortcutKey_keyHolder") - static let focusShortcut = Key("EZFocusShortcutKey_keyHolder") - static let playShortcut = Key("EZPlayShortcutKey_keyHolder") - static let retryShortcut = Key("EZRetryShortcutKey_keyHolder") - static let toggleShortcut = Key("EZToggleShortcutKey_keyHolder") - static let pinShortcut = Key("EZPinShortcutKey_keyHolder") - static let hideShortcut = Key("EZHideShortcutKey_keyHolder") - static let increaseFontSize = Key("EZIncreaseFontSizeShortcutKey_keyHolder") - static let decreaseFontSize = Key("EZDecreaseFontSizeShortcutKey_keyHolder") - static let googleShortcut = Key("EZGoogleShortcutKey_keyHolder") - static let eudicShortcut = Key("EZEudicShortcutKey_keyHolder") - static let appleDictionaryShortcut = Key("EZAppleDictionaryShortcutKey_keyHolder") + static let clearInputShortcut = Key("EZClearInputShortcutKey_keyHolder", default: KeyCombo(key: .k, cocoaModifiers: .command)) + static let clearAllShortcut = Key("EZClearAllShortcutKey_keyHolder", default: KeyCombo(key: .k, cocoaModifiers: [.command, .shift])) + static let copyShortcut = Key("EZCopyShortcutKey_keyHolder", default: KeyCombo(key: .c, cocoaModifiers: [.command, .shift])) + static let copyFirstResultShortcut = Key("EZCopyFirstResultShortcutKey_keyHolder", default: KeyCombo(key: .j, cocoaModifiers: [.command, .shift])) + static let focusShortcut = Key("EZFocusShortcutKey_keyHolder", default: KeyCombo(key: .i, cocoaModifiers: .command)) + static let playShortcut = Key("EZPlayShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .command)) + static let retryShortcut = Key("EZRetryShortcutKey_keyHolder", default: KeyCombo(key: .r, cocoaModifiers: .command)) + static let toggleShortcut = Key("EZToggleShortcutKey_keyHolder", default: KeyCombo(key: .t, cocoaModifiers: .command)) + static let pinShortcut = Key("EZPinShortcutKey_keyHolder", default: KeyCombo(key: .p, cocoaModifiers: .command)) + static let hideShortcut = Key("EZHideShortcutKey_keyHolder", default: KeyCombo(key: .y, cocoaModifiers: .command)) + static let increaseFontSize = Key("EZIncreaseFontSizeShortcutKey_keyHolder", default: KeyCombo(key: .keypadPlus, cocoaModifiers: .command)) + static let decreaseFontSize = Key("EZDecreaseFontSizeShortcutKey_keyHolder", default: KeyCombo(key: .keypadMinus, cocoaModifiers: .command)) + static let googleShortcut = Key("EZGoogleShortcutKey_keyHolder", default: KeyCombo(key: .return, cocoaModifiers: .command)) + static let eudicShortcut = Key("EZEudicShortcutKey_keyHolder", default: KeyCombo(key: .return, cocoaModifiers: [.command, .shift])) + static let appleDictionaryShortcut = Key("EZAppleDictionaryShortcutKey_keyHolder", default: KeyCombo(key: .d, cocoaModifiers: [.command, .shift])) } diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift index d48d74d1d..f24d8c5c3 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -8,24 +8,3 @@ import Defaults import Magnet - -extension Shortcut { - // set defalut for app shortcut - func setDefaultForAppShortcut() { - Defaults[.clearInputShortcut] = KeyCombo(key: .k, cocoaModifiers: .command) - Defaults[.clearAllShortcut] = KeyCombo(key: .k, cocoaModifiers: [.command, .shift]) - Defaults[.copyShortcut] = KeyCombo(key: .c, cocoaModifiers: [.command, .shift]) - Defaults[.copyFirstResultShortcut] = KeyCombo(key: .j, cocoaModifiers: [.command, .shift]) - Defaults[.focusShortcut] = KeyCombo(key: .i, cocoaModifiers: .command) - Defaults[.playShortcut] = KeyCombo(key: .s, cocoaModifiers: .command) - Defaults[.retryShortcut] = KeyCombo(key: .r, cocoaModifiers: .command) - Defaults[.toggleShortcut] = KeyCombo(key: .t, cocoaModifiers: .command) - Defaults[.pinShortcut] = KeyCombo(key: .p, cocoaModifiers: .command) - Defaults[.hideShortcut] = KeyCombo(key: .y, cocoaModifiers: .command) - Defaults[.increaseFontSize] = KeyCombo(key: .keypadPlus, cocoaModifiers: .command) - Defaults[.decreaseFontSize] = KeyCombo(key: .keypadMinus, cocoaModifiers: .command) - Defaults[.googleShortcut] = KeyCombo(key: .return, cocoaModifiers: .command) - Defaults[.eudicShortcut] = KeyCombo(key: .return, cocoaModifiers: [.command, .shift]) - Defaults[.appleDictionaryShortcut] = KeyCombo(key: .d, cocoaModifiers: [.command, .shift]) - } -} diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift index c08c2dc2a..d4be0b625 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift @@ -99,14 +99,6 @@ class Shortcut: NSObject { @objc static func setupShortcut() { let shortcut = Shortcut.shared shortcut.restoreShortcut() - - if Defaults[.firstLaunch] { - Defaults[.firstLaunch] = false - // set defalut for app shortcut - shortcut.setDefaultForAppShortcut() - } else { - // do nothing - } } // Make sure the class has only one instance From 3a2d7344f2733af6f1b0b3fc336260a85858b205 Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:23:00 -0800 Subject: [PATCH 02/14] refactor: delete unused file --- Easydict.xcodeproj/project.pbxproj | 4 ---- .../NewApp/Feature/Shortcut/Shortcut+Default.swift | 10 ---------- 2 files changed, 14 deletions(-) delete mode 100644 Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index a56b655cb..4c142dfe5 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -279,7 +279,6 @@ 9643D93D2B6F829C000FBEA6 /* MainMenuCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D93C2B6F829C000FBEA6 /* MainMenuCommand.swift */; }; 9643D9402B6FC426000FBEA6 /* MainMenuShortcutCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D93F2B6FC426000FBEA6 /* MainMenuShortcutCommand.swift */; }; 9643D9422B6FE4AF000FBEA6 /* Shortcut+Bind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */; }; - 9643D9442B6FEF5F000FBEA6 /* Shortcut+Default.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */; }; 9643D9462B71D103000FBEA6 /* KeyHolderRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9452B71D103000FBEA6 /* KeyHolderRowView.swift */; }; 9643D94A2B71EABE000FBEA6 /* KeyHolderAlterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9492B71EABE000FBEA6 /* KeyHolderAlterView.swift */; }; 9643D94C2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D94B2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift */; }; @@ -803,7 +802,6 @@ 9643D93C2B6F829C000FBEA6 /* MainMenuCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuCommand.swift; sourceTree = ""; }; 9643D93F2B6FC426000FBEA6 /* MainMenuShortcutCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuShortcutCommand.swift; sourceTree = ""; }; 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shortcut+Bind.swift"; sourceTree = ""; }; - 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shortcut+Default.swift"; sourceTree = ""; }; 9643D9452B71D103000FBEA6 /* KeyHolderRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyHolderRowView.swift; sourceTree = ""; }; 9643D9492B71EABE000FBEA6 /* KeyHolderAlterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyHolderAlterView.swift; sourceTree = ""; }; 9643D94B2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuShortcutCommandItem.swift; sourceTree = ""; }; @@ -2272,7 +2270,6 @@ isa = PBXGroup; children = ( 967712ED2B5B943400105E0F /* Shortcut.swift */, - 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */, 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */, 9608354F2B6791F200C6A931 /* Shortcut+Validator.swift */, 9643D9552B73B3CD000FBEA6 /* Shortcut+Menu.swift */, @@ -3003,7 +3000,6 @@ 03BDA7B92A26DA280079D04F /* NSProcessInfo+XPMArgumentParser.m in Sources */, 03542A4F2937B64B00C34C33 /* EZYoudaoOCRResponse.m in Sources */, 03B0233929231FA6001C7E63 /* MMTool.m in Sources */, - 9643D9442B6FEF5F000FBEA6 /* Shortcut+Default.swift in Sources */, 03542A552937B7DE00C34C33 /* EZError.m in Sources */, 17BCAEF72B0DFF9000A7D372 /* EZNiuTransTranslateResponse.m in Sources */, 03BDA7B82A26DA280079D04F /* XPMValuedArgument.m in Sources */, diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift deleted file mode 100644 index f24d8c5c3..000000000 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ /dev/null @@ -1,10 +0,0 @@ -// -// Shortcut+Default.swift -// Easydict -// -// Created by Sharker on 2024/2/5. -// Copyright © 2024 izual. All rights reserved. -// - -import Defaults -import Magnet From 1f35d8148a2d0048747c915ed1a495c8c8df58ce Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:07:33 -0800 Subject: [PATCH 03/14] Revert "refactor: delete unused file" This reverts commit 3a2d7344f2733af6f1b0b3fc336260a85858b205. --- Easydict.xcodeproj/project.pbxproj | 4 ++++ .../NewApp/Feature/Shortcut/Shortcut+Default.swift | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 4c142dfe5..a56b655cb 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -279,6 +279,7 @@ 9643D93D2B6F829C000FBEA6 /* MainMenuCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D93C2B6F829C000FBEA6 /* MainMenuCommand.swift */; }; 9643D9402B6FC426000FBEA6 /* MainMenuShortcutCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D93F2B6FC426000FBEA6 /* MainMenuShortcutCommand.swift */; }; 9643D9422B6FE4AF000FBEA6 /* Shortcut+Bind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */; }; + 9643D9442B6FEF5F000FBEA6 /* Shortcut+Default.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */; }; 9643D9462B71D103000FBEA6 /* KeyHolderRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9452B71D103000FBEA6 /* KeyHolderRowView.swift */; }; 9643D94A2B71EABE000FBEA6 /* KeyHolderAlterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9492B71EABE000FBEA6 /* KeyHolderAlterView.swift */; }; 9643D94C2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D94B2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift */; }; @@ -802,6 +803,7 @@ 9643D93C2B6F829C000FBEA6 /* MainMenuCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuCommand.swift; sourceTree = ""; }; 9643D93F2B6FC426000FBEA6 /* MainMenuShortcutCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuShortcutCommand.swift; sourceTree = ""; }; 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shortcut+Bind.swift"; sourceTree = ""; }; + 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shortcut+Default.swift"; sourceTree = ""; }; 9643D9452B71D103000FBEA6 /* KeyHolderRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyHolderRowView.swift; sourceTree = ""; }; 9643D9492B71EABE000FBEA6 /* KeyHolderAlterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyHolderAlterView.swift; sourceTree = ""; }; 9643D94B2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuShortcutCommandItem.swift; sourceTree = ""; }; @@ -2270,6 +2272,7 @@ isa = PBXGroup; children = ( 967712ED2B5B943400105E0F /* Shortcut.swift */, + 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */, 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */, 9608354F2B6791F200C6A931 /* Shortcut+Validator.swift */, 9643D9552B73B3CD000FBEA6 /* Shortcut+Menu.swift */, @@ -3000,6 +3003,7 @@ 03BDA7B92A26DA280079D04F /* NSProcessInfo+XPMArgumentParser.m in Sources */, 03542A4F2937B64B00C34C33 /* EZYoudaoOCRResponse.m in Sources */, 03B0233929231FA6001C7E63 /* MMTool.m in Sources */, + 9643D9442B6FEF5F000FBEA6 /* Shortcut+Default.swift in Sources */, 03542A552937B7DE00C34C33 /* EZError.m in Sources */, 17BCAEF72B0DFF9000A7D372 /* EZNiuTransTranslateResponse.m in Sources */, 03BDA7B82A26DA280079D04F /* XPMValuedArgument.m in Sources */, diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift new file mode 100644 index 000000000..f24d8c5c3 --- /dev/null +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -0,0 +1,10 @@ +// +// Shortcut+Default.swift +// Easydict +// +// Created by Sharker on 2024/2/5. +// Copyright © 2024 izual. All rights reserved. +// + +import Defaults +import Magnet From 3e18acc9fd8904451ab4f568296cea0f0a504beb Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:07:37 -0800 Subject: [PATCH 04/14] Revert "fix: default value in short cut" This reverts commit fdfe49574f9b8e5f9d88b35a0dae655268a2360e. --- .../Configuration+Defaults.swift | 46 +++++++++++-------- .../Feature/Shortcut/Shortcut+Default.swift | 21 +++++++++ .../NewApp/Feature/Shortcut/Shortcut.swift | 8 ++++ 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/Easydict/NewApp/Configuration/Configuration+Defaults.swift b/Easydict/NewApp/Configuration/Configuration+Defaults.swift index ea4839965..240aed001 100644 --- a/Easydict/NewApp/Configuration/Configuration+Defaults.swift +++ b/Easydict/NewApp/Configuration/Configuration+Defaults.swift @@ -10,6 +10,12 @@ import Defaults import Foundation import Magnet +/// Utils +extension Defaults.Keys { + /// is first launch + static let firstLaunch = Key("EZConfiguration_kFirstLaunch", default: true) +} + // Setting extension Defaults.Keys { // rename `from` @@ -172,26 +178,26 @@ extension Defaults.Keys { /// shortcut extension Defaults.Keys { // Global - static let selectionShortcut = Key("EZSelectionShortcutKey_keyHolder", default: KeyCombo(key: .d, cocoaModifiers: .option)) - static let snipShortcut = Key("EZSnipShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .option)) - static let inputShortcut = Key("EZInputShortcutKey_keyHolder", default: KeyCombo(key: .a, cocoaModifiers: .option)) - static let screenshotOCRShortcut = Key("EZScreenshotOCRShortcutKey_keyHolder", default: KeyCombo(key: .f, cocoaModifiers: [.option, .shift])) - static let showMiniWindowShortcut = Key("EZShowMiniShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .option)) + static let selectionShortcut = Key("EZSelectionShortcutKey_keyHolder") + static let snipShortcut = Key("EZSnipShortcutKey_keyHolder") + static let inputShortcut = Key("EZInputShortcutKey_keyHolder") + static let screenshotOCRShortcut = Key("EZScreenshotOCRShortcutKey_keyHolder") + static let showMiniWindowShortcut = Key("EZShowMiniShortcutKey_keyHolder") // App - static let clearInputShortcut = Key("EZClearInputShortcutKey_keyHolder", default: KeyCombo(key: .k, cocoaModifiers: .command)) - static let clearAllShortcut = Key("EZClearAllShortcutKey_keyHolder", default: KeyCombo(key: .k, cocoaModifiers: [.command, .shift])) - static let copyShortcut = Key("EZCopyShortcutKey_keyHolder", default: KeyCombo(key: .c, cocoaModifiers: [.command, .shift])) - static let copyFirstResultShortcut = Key("EZCopyFirstResultShortcutKey_keyHolder", default: KeyCombo(key: .j, cocoaModifiers: [.command, .shift])) - static let focusShortcut = Key("EZFocusShortcutKey_keyHolder", default: KeyCombo(key: .i, cocoaModifiers: .command)) - static let playShortcut = Key("EZPlayShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .command)) - static let retryShortcut = Key("EZRetryShortcutKey_keyHolder", default: KeyCombo(key: .r, cocoaModifiers: .command)) - static let toggleShortcut = Key("EZToggleShortcutKey_keyHolder", default: KeyCombo(key: .t, cocoaModifiers: .command)) - static let pinShortcut = Key("EZPinShortcutKey_keyHolder", default: KeyCombo(key: .p, cocoaModifiers: .command)) - static let hideShortcut = Key("EZHideShortcutKey_keyHolder", default: KeyCombo(key: .y, cocoaModifiers: .command)) - static let increaseFontSize = Key("EZIncreaseFontSizeShortcutKey_keyHolder", default: KeyCombo(key: .keypadPlus, cocoaModifiers: .command)) - static let decreaseFontSize = Key("EZDecreaseFontSizeShortcutKey_keyHolder", default: KeyCombo(key: .keypadMinus, cocoaModifiers: .command)) - static let googleShortcut = Key("EZGoogleShortcutKey_keyHolder", default: KeyCombo(key: .return, cocoaModifiers: .command)) - static let eudicShortcut = Key("EZEudicShortcutKey_keyHolder", default: KeyCombo(key: .return, cocoaModifiers: [.command, .shift])) - static let appleDictionaryShortcut = Key("EZAppleDictionaryShortcutKey_keyHolder", default: KeyCombo(key: .d, cocoaModifiers: [.command, .shift])) + static let clearInputShortcut = Key("EZClearInputShortcutKey_keyHolder") + static let clearAllShortcut = Key("EZClearAllShortcutKey_keyHolder") + static let copyShortcut = Key("EZCopyShortcutKey_keyHolder") + static let copyFirstResultShortcut = Key("EZCopyFirstResultShortcutKey_keyHolder") + static let focusShortcut = Key("EZFocusShortcutKey_keyHolder") + static let playShortcut = Key("EZPlayShortcutKey_keyHolder") + static let retryShortcut = Key("EZRetryShortcutKey_keyHolder") + static let toggleShortcut = Key("EZToggleShortcutKey_keyHolder") + static let pinShortcut = Key("EZPinShortcutKey_keyHolder") + static let hideShortcut = Key("EZHideShortcutKey_keyHolder") + static let increaseFontSize = Key("EZIncreaseFontSizeShortcutKey_keyHolder") + static let decreaseFontSize = Key("EZDecreaseFontSizeShortcutKey_keyHolder") + static let googleShortcut = Key("EZGoogleShortcutKey_keyHolder") + static let eudicShortcut = Key("EZEudicShortcutKey_keyHolder") + static let appleDictionaryShortcut = Key("EZAppleDictionaryShortcutKey_keyHolder") } diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift index f24d8c5c3..d48d74d1d 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -8,3 +8,24 @@ import Defaults import Magnet + +extension Shortcut { + // set defalut for app shortcut + func setDefaultForAppShortcut() { + Defaults[.clearInputShortcut] = KeyCombo(key: .k, cocoaModifiers: .command) + Defaults[.clearAllShortcut] = KeyCombo(key: .k, cocoaModifiers: [.command, .shift]) + Defaults[.copyShortcut] = KeyCombo(key: .c, cocoaModifiers: [.command, .shift]) + Defaults[.copyFirstResultShortcut] = KeyCombo(key: .j, cocoaModifiers: [.command, .shift]) + Defaults[.focusShortcut] = KeyCombo(key: .i, cocoaModifiers: .command) + Defaults[.playShortcut] = KeyCombo(key: .s, cocoaModifiers: .command) + Defaults[.retryShortcut] = KeyCombo(key: .r, cocoaModifiers: .command) + Defaults[.toggleShortcut] = KeyCombo(key: .t, cocoaModifiers: .command) + Defaults[.pinShortcut] = KeyCombo(key: .p, cocoaModifiers: .command) + Defaults[.hideShortcut] = KeyCombo(key: .y, cocoaModifiers: .command) + Defaults[.increaseFontSize] = KeyCombo(key: .keypadPlus, cocoaModifiers: .command) + Defaults[.decreaseFontSize] = KeyCombo(key: .keypadMinus, cocoaModifiers: .command) + Defaults[.googleShortcut] = KeyCombo(key: .return, cocoaModifiers: .command) + Defaults[.eudicShortcut] = KeyCombo(key: .return, cocoaModifiers: [.command, .shift]) + Defaults[.appleDictionaryShortcut] = KeyCombo(key: .d, cocoaModifiers: [.command, .shift]) + } +} diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift index d4be0b625..c08c2dc2a 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift @@ -99,6 +99,14 @@ class Shortcut: NSObject { @objc static func setupShortcut() { let shortcut = Shortcut.shared shortcut.restoreShortcut() + + if Defaults[.firstLaunch] { + Defaults[.firstLaunch] = false + // set defalut for app shortcut + shortcut.setDefaultForAppShortcut() + } else { + // do nothing + } } // Make sure the class has only one instance From 53d7eec3807d31a27b9f6fae11caab9c00318f2b Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:19:59 -0800 Subject: [PATCH 05/14] Add default shortcut --- Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift index d48d74d1d..2d3079f8b 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -12,6 +12,12 @@ import Magnet extension Shortcut { // set defalut for app shortcut func setDefaultForAppShortcut() { + Defaults[.selectionShortcut] = KeyCombo(key: .d, cocoaModifiers: .option) + Defaults[.snipShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) + Defaults[.inputShortcut] = KeyCombo(key: .a, cocoaModifiers: .option) + Defaults[.screenshotOCRShortcut] = KeyCombo(key: .f, cocoaModifiers: [.option, .shift]) + Defaults[.showMiniWindowShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) + Defaults[.clearInputShortcut] = KeyCombo(key: .k, cocoaModifiers: .command) Defaults[.clearAllShortcut] = KeyCombo(key: .k, cocoaModifiers: [.command, .shift]) Defaults[.copyShortcut] = KeyCombo(key: .c, cocoaModifiers: [.command, .shift]) From 27bca4f1192bbe2dc82f3fc5e8507c20bb5f4132 Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:57:31 -0800 Subject: [PATCH 06/14] split `setDefaultForAppShortcut` into 2 method --- .../NewApp/Feature/Shortcut/Shortcut+Default.swift | 11 ++++++++++- Easydict/NewApp/Feature/Shortcut/Shortcut.swift | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift index 2d3079f8b..8dbcaba42 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -11,12 +11,21 @@ import Magnet extension Shortcut { // set defalut for app shortcut - func setDefaultForAppShortcut() { + func setDefaultForShortcut() { + setDefaultForGlobalShortcut() + setDefaultForAppShortcut() + } + + private func setDefaultForGlobalShortcut() { Defaults[.selectionShortcut] = KeyCombo(key: .d, cocoaModifiers: .option) Defaults[.snipShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) Defaults[.inputShortcut] = KeyCombo(key: .a, cocoaModifiers: .option) Defaults[.screenshotOCRShortcut] = KeyCombo(key: .f, cocoaModifiers: [.option, .shift]) Defaults[.showMiniWindowShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) + } + + private func setDefaultForAppShortcut() { + setDefaultForGlobalShortcut() Defaults[.clearInputShortcut] = KeyCombo(key: .k, cocoaModifiers: .command) Defaults[.clearAllShortcut] = KeyCombo(key: .k, cocoaModifiers: [.command, .shift]) diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift index c08c2dc2a..78b54d58f 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift @@ -103,7 +103,7 @@ class Shortcut: NSObject { if Defaults[.firstLaunch] { Defaults[.firstLaunch] = false // set defalut for app shortcut - shortcut.setDefaultForAppShortcut() + shortcut.setDefaultForShortcut() } else { // do nothing } From 75895a012df62d4d1938f2e4cb13b64c64532413 Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:20:08 -0800 Subject: [PATCH 07/14] fix: default value in short cut --- .../NewApp/Feature/Shortcut/Shortcut+Default.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift new file mode 100644 index 000000000..f24d8c5c3 --- /dev/null +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -0,0 +1,10 @@ +// +// Shortcut+Default.swift +// Easydict +// +// Created by Sharker on 2024/2/5. +// Copyright © 2024 izual. All rights reserved. +// + +import Defaults +import Magnet From e49842c83530a855c4fdbb22d6d6b0b6d6908fb7 Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:23:00 -0800 Subject: [PATCH 08/14] refactor: delete unused file --- .../NewApp/Feature/Shortcut/Shortcut+Default.swift | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift deleted file mode 100644 index f24d8c5c3..000000000 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ /dev/null @@ -1,10 +0,0 @@ -// -// Shortcut+Default.swift -// Easydict -// -// Created by Sharker on 2024/2/5. -// Copyright © 2024 izual. All rights reserved. -// - -import Defaults -import Magnet From e11f37729a65f3cc0f99b26524935b05fdbf75d5 Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:07:33 -0800 Subject: [PATCH 09/14] Revert "refactor: delete unused file" This reverts commit 3a2d7344f2733af6f1b0b3fc336260a85858b205. --- Easydict.xcodeproj/project.pbxproj | 4 ++++ .../NewApp/Feature/Shortcut/Shortcut+Default.swift | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 4c142dfe5..a56b655cb 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -279,6 +279,7 @@ 9643D93D2B6F829C000FBEA6 /* MainMenuCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D93C2B6F829C000FBEA6 /* MainMenuCommand.swift */; }; 9643D9402B6FC426000FBEA6 /* MainMenuShortcutCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D93F2B6FC426000FBEA6 /* MainMenuShortcutCommand.swift */; }; 9643D9422B6FE4AF000FBEA6 /* Shortcut+Bind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */; }; + 9643D9442B6FEF5F000FBEA6 /* Shortcut+Default.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */; }; 9643D9462B71D103000FBEA6 /* KeyHolderRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9452B71D103000FBEA6 /* KeyHolderRowView.swift */; }; 9643D94A2B71EABE000FBEA6 /* KeyHolderAlterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D9492B71EABE000FBEA6 /* KeyHolderAlterView.swift */; }; 9643D94C2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9643D94B2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift */; }; @@ -802,6 +803,7 @@ 9643D93C2B6F829C000FBEA6 /* MainMenuCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuCommand.swift; sourceTree = ""; }; 9643D93F2B6FC426000FBEA6 /* MainMenuShortcutCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuShortcutCommand.swift; sourceTree = ""; }; 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shortcut+Bind.swift"; sourceTree = ""; }; + 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shortcut+Default.swift"; sourceTree = ""; }; 9643D9452B71D103000FBEA6 /* KeyHolderRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyHolderRowView.swift; sourceTree = ""; }; 9643D9492B71EABE000FBEA6 /* KeyHolderAlterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyHolderAlterView.swift; sourceTree = ""; }; 9643D94B2B71F74D000FBEA6 /* MainMenuShortcutCommandItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuShortcutCommandItem.swift; sourceTree = ""; }; @@ -2270,6 +2272,7 @@ isa = PBXGroup; children = ( 967712ED2B5B943400105E0F /* Shortcut.swift */, + 9643D9432B6FEF5F000FBEA6 /* Shortcut+Default.swift */, 9643D9412B6FE4AF000FBEA6 /* Shortcut+Bind.swift */, 9608354F2B6791F200C6A931 /* Shortcut+Validator.swift */, 9643D9552B73B3CD000FBEA6 /* Shortcut+Menu.swift */, @@ -3000,6 +3003,7 @@ 03BDA7B92A26DA280079D04F /* NSProcessInfo+XPMArgumentParser.m in Sources */, 03542A4F2937B64B00C34C33 /* EZYoudaoOCRResponse.m in Sources */, 03B0233929231FA6001C7E63 /* MMTool.m in Sources */, + 9643D9442B6FEF5F000FBEA6 /* Shortcut+Default.swift in Sources */, 03542A552937B7DE00C34C33 /* EZError.m in Sources */, 17BCAEF72B0DFF9000A7D372 /* EZNiuTransTranslateResponse.m in Sources */, 03BDA7B82A26DA280079D04F /* XPMValuedArgument.m in Sources */, diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift new file mode 100644 index 000000000..f24d8c5c3 --- /dev/null +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -0,0 +1,10 @@ +// +// Shortcut+Default.swift +// Easydict +// +// Created by Sharker on 2024/2/5. +// Copyright © 2024 izual. All rights reserved. +// + +import Defaults +import Magnet From 6afe5c496a4bfdffdd09d816ea17ecf8df5877d6 Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:07:37 -0800 Subject: [PATCH 10/14] Revert "fix: default value in short cut" This reverts commit fdfe49574f9b8e5f9d88b35a0dae655268a2360e. --- .../Configuration+Defaults.swift | 46 +++++++++++-------- .../Feature/Shortcut/Shortcut+Default.swift | 21 +++++++++ .../NewApp/Feature/Shortcut/Shortcut.swift | 8 ++++ 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/Easydict/NewApp/Configuration/Configuration+Defaults.swift b/Easydict/NewApp/Configuration/Configuration+Defaults.swift index ea4839965..240aed001 100644 --- a/Easydict/NewApp/Configuration/Configuration+Defaults.swift +++ b/Easydict/NewApp/Configuration/Configuration+Defaults.swift @@ -10,6 +10,12 @@ import Defaults import Foundation import Magnet +/// Utils +extension Defaults.Keys { + /// is first launch + static let firstLaunch = Key("EZConfiguration_kFirstLaunch", default: true) +} + // Setting extension Defaults.Keys { // rename `from` @@ -172,26 +178,26 @@ extension Defaults.Keys { /// shortcut extension Defaults.Keys { // Global - static let selectionShortcut = Key("EZSelectionShortcutKey_keyHolder", default: KeyCombo(key: .d, cocoaModifiers: .option)) - static let snipShortcut = Key("EZSnipShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .option)) - static let inputShortcut = Key("EZInputShortcutKey_keyHolder", default: KeyCombo(key: .a, cocoaModifiers: .option)) - static let screenshotOCRShortcut = Key("EZScreenshotOCRShortcutKey_keyHolder", default: KeyCombo(key: .f, cocoaModifiers: [.option, .shift])) - static let showMiniWindowShortcut = Key("EZShowMiniShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .option)) + static let selectionShortcut = Key("EZSelectionShortcutKey_keyHolder") + static let snipShortcut = Key("EZSnipShortcutKey_keyHolder") + static let inputShortcut = Key("EZInputShortcutKey_keyHolder") + static let screenshotOCRShortcut = Key("EZScreenshotOCRShortcutKey_keyHolder") + static let showMiniWindowShortcut = Key("EZShowMiniShortcutKey_keyHolder") // App - static let clearInputShortcut = Key("EZClearInputShortcutKey_keyHolder", default: KeyCombo(key: .k, cocoaModifiers: .command)) - static let clearAllShortcut = Key("EZClearAllShortcutKey_keyHolder", default: KeyCombo(key: .k, cocoaModifiers: [.command, .shift])) - static let copyShortcut = Key("EZCopyShortcutKey_keyHolder", default: KeyCombo(key: .c, cocoaModifiers: [.command, .shift])) - static let copyFirstResultShortcut = Key("EZCopyFirstResultShortcutKey_keyHolder", default: KeyCombo(key: .j, cocoaModifiers: [.command, .shift])) - static let focusShortcut = Key("EZFocusShortcutKey_keyHolder", default: KeyCombo(key: .i, cocoaModifiers: .command)) - static let playShortcut = Key("EZPlayShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .command)) - static let retryShortcut = Key("EZRetryShortcutKey_keyHolder", default: KeyCombo(key: .r, cocoaModifiers: .command)) - static let toggleShortcut = Key("EZToggleShortcutKey_keyHolder", default: KeyCombo(key: .t, cocoaModifiers: .command)) - static let pinShortcut = Key("EZPinShortcutKey_keyHolder", default: KeyCombo(key: .p, cocoaModifiers: .command)) - static let hideShortcut = Key("EZHideShortcutKey_keyHolder", default: KeyCombo(key: .y, cocoaModifiers: .command)) - static let increaseFontSize = Key("EZIncreaseFontSizeShortcutKey_keyHolder", default: KeyCombo(key: .keypadPlus, cocoaModifiers: .command)) - static let decreaseFontSize = Key("EZDecreaseFontSizeShortcutKey_keyHolder", default: KeyCombo(key: .keypadMinus, cocoaModifiers: .command)) - static let googleShortcut = Key("EZGoogleShortcutKey_keyHolder", default: KeyCombo(key: .return, cocoaModifiers: .command)) - static let eudicShortcut = Key("EZEudicShortcutKey_keyHolder", default: KeyCombo(key: .return, cocoaModifiers: [.command, .shift])) - static let appleDictionaryShortcut = Key("EZAppleDictionaryShortcutKey_keyHolder", default: KeyCombo(key: .d, cocoaModifiers: [.command, .shift])) + static let clearInputShortcut = Key("EZClearInputShortcutKey_keyHolder") + static let clearAllShortcut = Key("EZClearAllShortcutKey_keyHolder") + static let copyShortcut = Key("EZCopyShortcutKey_keyHolder") + static let copyFirstResultShortcut = Key("EZCopyFirstResultShortcutKey_keyHolder") + static let focusShortcut = Key("EZFocusShortcutKey_keyHolder") + static let playShortcut = Key("EZPlayShortcutKey_keyHolder") + static let retryShortcut = Key("EZRetryShortcutKey_keyHolder") + static let toggleShortcut = Key("EZToggleShortcutKey_keyHolder") + static let pinShortcut = Key("EZPinShortcutKey_keyHolder") + static let hideShortcut = Key("EZHideShortcutKey_keyHolder") + static let increaseFontSize = Key("EZIncreaseFontSizeShortcutKey_keyHolder") + static let decreaseFontSize = Key("EZDecreaseFontSizeShortcutKey_keyHolder") + static let googleShortcut = Key("EZGoogleShortcutKey_keyHolder") + static let eudicShortcut = Key("EZEudicShortcutKey_keyHolder") + static let appleDictionaryShortcut = Key("EZAppleDictionaryShortcutKey_keyHolder") } diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift index f24d8c5c3..d48d74d1d 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -8,3 +8,24 @@ import Defaults import Magnet + +extension Shortcut { + // set defalut for app shortcut + func setDefaultForAppShortcut() { + Defaults[.clearInputShortcut] = KeyCombo(key: .k, cocoaModifiers: .command) + Defaults[.clearAllShortcut] = KeyCombo(key: .k, cocoaModifiers: [.command, .shift]) + Defaults[.copyShortcut] = KeyCombo(key: .c, cocoaModifiers: [.command, .shift]) + Defaults[.copyFirstResultShortcut] = KeyCombo(key: .j, cocoaModifiers: [.command, .shift]) + Defaults[.focusShortcut] = KeyCombo(key: .i, cocoaModifiers: .command) + Defaults[.playShortcut] = KeyCombo(key: .s, cocoaModifiers: .command) + Defaults[.retryShortcut] = KeyCombo(key: .r, cocoaModifiers: .command) + Defaults[.toggleShortcut] = KeyCombo(key: .t, cocoaModifiers: .command) + Defaults[.pinShortcut] = KeyCombo(key: .p, cocoaModifiers: .command) + Defaults[.hideShortcut] = KeyCombo(key: .y, cocoaModifiers: .command) + Defaults[.increaseFontSize] = KeyCombo(key: .keypadPlus, cocoaModifiers: .command) + Defaults[.decreaseFontSize] = KeyCombo(key: .keypadMinus, cocoaModifiers: .command) + Defaults[.googleShortcut] = KeyCombo(key: .return, cocoaModifiers: .command) + Defaults[.eudicShortcut] = KeyCombo(key: .return, cocoaModifiers: [.command, .shift]) + Defaults[.appleDictionaryShortcut] = KeyCombo(key: .d, cocoaModifiers: [.command, .shift]) + } +} diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift index d4be0b625..c08c2dc2a 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift @@ -99,6 +99,14 @@ class Shortcut: NSObject { @objc static func setupShortcut() { let shortcut = Shortcut.shared shortcut.restoreShortcut() + + if Defaults[.firstLaunch] { + Defaults[.firstLaunch] = false + // set defalut for app shortcut + shortcut.setDefaultForAppShortcut() + } else { + // do nothing + } } // Make sure the class has only one instance From 5b58be47acbc4a0dd49eb8d05141035f5fb4958a Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:19:59 -0800 Subject: [PATCH 11/14] Add default shortcut --- Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift index d48d74d1d..2d3079f8b 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -12,6 +12,12 @@ import Magnet extension Shortcut { // set defalut for app shortcut func setDefaultForAppShortcut() { + Defaults[.selectionShortcut] = KeyCombo(key: .d, cocoaModifiers: .option) + Defaults[.snipShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) + Defaults[.inputShortcut] = KeyCombo(key: .a, cocoaModifiers: .option) + Defaults[.screenshotOCRShortcut] = KeyCombo(key: .f, cocoaModifiers: [.option, .shift]) + Defaults[.showMiniWindowShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) + Defaults[.clearInputShortcut] = KeyCombo(key: .k, cocoaModifiers: .command) Defaults[.clearAllShortcut] = KeyCombo(key: .k, cocoaModifiers: [.command, .shift]) Defaults[.copyShortcut] = KeyCombo(key: .c, cocoaModifiers: [.command, .shift]) From e5c92af1cc7c55c49be63b860d65f74e1ef3cdab Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:57:31 -0800 Subject: [PATCH 12/14] split `setDefaultForAppShortcut` into 2 method --- .../NewApp/Feature/Shortcut/Shortcut+Default.swift | 11 ++++++++++- Easydict/NewApp/Feature/Shortcut/Shortcut.swift | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift index 2d3079f8b..8dbcaba42 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -11,12 +11,21 @@ import Magnet extension Shortcut { // set defalut for app shortcut - func setDefaultForAppShortcut() { + func setDefaultForShortcut() { + setDefaultForGlobalShortcut() + setDefaultForAppShortcut() + } + + private func setDefaultForGlobalShortcut() { Defaults[.selectionShortcut] = KeyCombo(key: .d, cocoaModifiers: .option) Defaults[.snipShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) Defaults[.inputShortcut] = KeyCombo(key: .a, cocoaModifiers: .option) Defaults[.screenshotOCRShortcut] = KeyCombo(key: .f, cocoaModifiers: [.option, .shift]) Defaults[.showMiniWindowShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) + } + + private func setDefaultForAppShortcut() { + setDefaultForGlobalShortcut() Defaults[.clearInputShortcut] = KeyCombo(key: .k, cocoaModifiers: .command) Defaults[.clearAllShortcut] = KeyCombo(key: .k, cocoaModifiers: [.command, .shift]) diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift index c08c2dc2a..78b54d58f 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift @@ -103,7 +103,7 @@ class Shortcut: NSObject { if Defaults[.firstLaunch] { Defaults[.firstLaunch] = false // set defalut for app shortcut - shortcut.setDefaultForAppShortcut() + shortcut.setDefaultForShortcut() } else { // do nothing } From f77be6546c4b8c99e1fe364c6be617b4c9bca6e7 Mon Sep 17 00:00:00 2001 From: Lava <34743145+CanglongCl@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:06:51 -0800 Subject: [PATCH 13/14] Revert "chore: update issue templates" This reverts commit 033e391917820787a3108b1a01cdf291be0c197f. --- .github/ISSUE_TEMPLATE/cn_bug_report_zh.yml | 4 +--- .github/ISSUE_TEMPLATE/en_bug_report.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/cn_bug_report_zh.yml b/.github/ISSUE_TEMPLATE/cn_bug_report_zh.yml index e3de84e43..c2d0f068a 100644 --- a/.github/ISSUE_TEMPLATE/cn_bug_report_zh.yml +++ b/.github/ISSUE_TEMPLATE/cn_bug_report_zh.yml @@ -1,6 +1,6 @@ name: 反馈问题 description: 反馈问题 -title: "🐞 反馈问题:请填写标题,不要留空" +title: "🐞 反馈问题:{{请填写标题,不要留空}}" labels: ["bug"] body: @@ -9,8 +9,6 @@ body: attributes: label: 请先确认以下事项: options: - - label: 请务必查看 [常见问题](https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98) - required: true - label: 已仔细阅读了 [README](https://github.com/tisfeng/Easydict#readme) required: true - label: 在 [issues](https://github.com/tisfeng/Easydict/issues) 页面搜索过问题(包括已关闭的 issue),但未能找到解决方法 diff --git a/.github/ISSUE_TEMPLATE/en_bug_report.yml b/.github/ISSUE_TEMPLATE/en_bug_report.yml index 5b51b73a6..2f87973a8 100644 --- a/.github/ISSUE_TEMPLATE/en_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/en_bug_report.yml @@ -1,6 +1,6 @@ name: Bug report description: Report an issue -title: "🐞 Bug Report: Please fill in the title, don't leave it blank" +title: "🐞 Bug Report: {{Please fill in the title, don't leave it blank}} " labels: ["bug"] body: @@ -9,8 +9,6 @@ body: attributes: label: "Please confirm the following:" options: - - label: Be sure to check out [FAQ](https://github.com/tisfeng/Easydict/wiki/FAQ) - required: true - label: I have carefully read the [README](https://github.com/tisfeng/Easydict#readme) required: true - label: I have searched through the [issues](https://github.com/tisfeng/Easydict/issues) page but couldn't find a solution.(Including issue that has been closed) From 875083acd2acae92fa52b3243c4bcd79af43c2e7 Mon Sep 17 00:00:00 2001 From: tisfeng Date: Tue, 13 Feb 2024 09:59:52 +0800 Subject: [PATCH 14/14] fix: correct default global shortcut keys --- Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift index 8dbcaba42..685cfa026 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift @@ -17,11 +17,11 @@ extension Shortcut { } private func setDefaultForGlobalShortcut() { - Defaults[.selectionShortcut] = KeyCombo(key: .d, cocoaModifiers: .option) - Defaults[.snipShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) Defaults[.inputShortcut] = KeyCombo(key: .a, cocoaModifiers: .option) - Defaults[.screenshotOCRShortcut] = KeyCombo(key: .f, cocoaModifiers: [.option, .shift]) - Defaults[.showMiniWindowShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) + Defaults[.snipShortcut] = KeyCombo(key: .s, cocoaModifiers: .option) + Defaults[.selectionShortcut] = KeyCombo(key: .d, cocoaModifiers: .option) + Defaults[.showMiniWindowShortcut] = KeyCombo(key: .f, cocoaModifiers: .option) + Defaults[.screenshotOCRShortcut] = KeyCombo(key: .s, cocoaModifiers: [.option, .shift]) } private func setDefaultForAppShortcut() {