Skip to content

Commit

Permalink
fix: default value in short cut
Browse files Browse the repository at this point in the history
  • Loading branch information
CanglongCl committed Feb 9, 2024
1 parent 0de18ae commit fdfe495
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 55 deletions.
46 changes: 20 additions & 26 deletions Easydict/NewApp/Configuration/Configuration+Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import Defaults
import Foundation
import Magnet

/// Utils
extension Defaults.Keys {
/// is first launch
static let firstLaunch = Key<Bool>("EZConfiguration_kFirstLaunch", default: true)
}

// Setting
extension Defaults.Keys {
// rename `from`
Expand Down Expand Up @@ -178,26 +172,26 @@ extension Defaults.Keys {
/// shortcut
extension Defaults.Keys {
// Global
static let selectionShortcut = Key<KeyCombo?>("EZSelectionShortcutKey_keyHolder")
static let snipShortcut = Key<KeyCombo?>("EZSnipShortcutKey_keyHolder")
static let inputShortcut = Key<KeyCombo?>("EZInputShortcutKey_keyHolder")
static let screenshotOCRShortcut = Key<KeyCombo?>("EZScreenshotOCRShortcutKey_keyHolder")
static let showMiniWindowShortcut = Key<KeyCombo?>("EZShowMiniShortcutKey_keyHolder")
static let selectionShortcut = Key<KeyCombo?>("EZSelectionShortcutKey_keyHolder", default: KeyCombo(key: .d, cocoaModifiers: .option))
static let snipShortcut = Key<KeyCombo?>("EZSnipShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .option))
static let inputShortcut = Key<KeyCombo?>("EZInputShortcutKey_keyHolder", default: KeyCombo(key: .a, cocoaModifiers: .option))
static let screenshotOCRShortcut = Key<KeyCombo?>("EZScreenshotOCRShortcutKey_keyHolder", default: KeyCombo(key: .f, cocoaModifiers: [.option, .shift]))
static let showMiniWindowShortcut = Key<KeyCombo?>("EZShowMiniShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .option))

// App
static let clearInputShortcut = Key<KeyCombo?>("EZClearInputShortcutKey_keyHolder")
static let clearAllShortcut = Key<KeyCombo?>("EZClearAllShortcutKey_keyHolder")
static let copyShortcut = Key<KeyCombo?>("EZCopyShortcutKey_keyHolder")
static let copyFirstResultShortcut = Key<KeyCombo?>("EZCopyFirstResultShortcutKey_keyHolder")
static let focusShortcut = Key<KeyCombo?>("EZFocusShortcutKey_keyHolder")
static let playShortcut = Key<KeyCombo?>("EZPlayShortcutKey_keyHolder")
static let retryShortcut = Key<KeyCombo?>("EZRetryShortcutKey_keyHolder")
static let toggleShortcut = Key<KeyCombo?>("EZToggleShortcutKey_keyHolder")
static let pinShortcut = Key<KeyCombo?>("EZPinShortcutKey_keyHolder")
static let hideShortcut = Key<KeyCombo?>("EZHideShortcutKey_keyHolder")
static let increaseFontSize = Key<KeyCombo?>("EZIncreaseFontSizeShortcutKey_keyHolder")
static let decreaseFontSize = Key<KeyCombo?>("EZDecreaseFontSizeShortcutKey_keyHolder")
static let googleShortcut = Key<KeyCombo?>("EZGoogleShortcutKey_keyHolder")
static let eudicShortcut = Key<KeyCombo?>("EZEudicShortcutKey_keyHolder")
static let appleDictionaryShortcut = Key<KeyCombo?>("EZAppleDictionaryShortcutKey_keyHolder")
static let clearInputShortcut = Key<KeyCombo?>("EZClearInputShortcutKey_keyHolder", default: KeyCombo(key: .k, cocoaModifiers: .command))
static let clearAllShortcut = Key<KeyCombo?>("EZClearAllShortcutKey_keyHolder", default: KeyCombo(key: .k, cocoaModifiers: [.command, .shift]))
static let copyShortcut = Key<KeyCombo?>("EZCopyShortcutKey_keyHolder", default: KeyCombo(key: .c, cocoaModifiers: [.command, .shift]))
static let copyFirstResultShortcut = Key<KeyCombo?>("EZCopyFirstResultShortcutKey_keyHolder", default: KeyCombo(key: .j, cocoaModifiers: [.command, .shift]))
static let focusShortcut = Key<KeyCombo?>("EZFocusShortcutKey_keyHolder", default: KeyCombo(key: .i, cocoaModifiers: .command))
static let playShortcut = Key<KeyCombo?>("EZPlayShortcutKey_keyHolder", default: KeyCombo(key: .s, cocoaModifiers: .command))
static let retryShortcut = Key<KeyCombo?>("EZRetryShortcutKey_keyHolder", default: KeyCombo(key: .r, cocoaModifiers: .command))
static let toggleShortcut = Key<KeyCombo?>("EZToggleShortcutKey_keyHolder", default: KeyCombo(key: .t, cocoaModifiers: .command))
static let pinShortcut = Key<KeyCombo?>("EZPinShortcutKey_keyHolder", default: KeyCombo(key: .p, cocoaModifiers: .command))
static let hideShortcut = Key<KeyCombo?>("EZHideShortcutKey_keyHolder", default: KeyCombo(key: .y, cocoaModifiers: .command))
static let increaseFontSize = Key<KeyCombo?>("EZIncreaseFontSizeShortcutKey_keyHolder", default: KeyCombo(key: .keypadPlus, cocoaModifiers: .command))
static let decreaseFontSize = Key<KeyCombo?>("EZDecreaseFontSizeShortcutKey_keyHolder", default: KeyCombo(key: .keypadMinus, cocoaModifiers: .command))
static let googleShortcut = Key<KeyCombo?>("EZGoogleShortcutKey_keyHolder", default: KeyCombo(key: .return, cocoaModifiers: .command))
static let eudicShortcut = Key<KeyCombo?>("EZEudicShortcutKey_keyHolder", default: KeyCombo(key: .return, cocoaModifiers: [.command, .shift]))
static let appleDictionaryShortcut = Key<KeyCombo?>("EZAppleDictionaryShortcutKey_keyHolder", default: KeyCombo(key: .d, cocoaModifiers: [.command, .shift]))
}
21 changes: 0 additions & 21 deletions Easydict/NewApp/Feature/Shortcut/Shortcut+Default.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
}
8 changes: 0 additions & 8 deletions Easydict/NewApp/Feature/Shortcut/Shortcut.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fdfe495

Please sign in to comment.