Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add double click modifier as shortcut #277

Merged
merged 13 commits into from
Dec 30, 2023
Merged
6 changes: 6 additions & 0 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
6295DE342A84EF76006145F4 /* EZBingLookupModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6295DE332A84EF76006145F4 /* EZBingLookupModel.m */; };
62A2D03F2A82967F007EEB01 /* EZBingRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 62A2D03E2A82967F007EEB01 /* EZBingRequest.m */; };
62ED29A22B15F1F500901F51 /* EZWrapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 62ED29A12B15F1F500901F51 /* EZWrapView.m */; };
9672D7D22B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m in Sources */ = {isa = PBXBuildFile; fileRef = 9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */; };
A0B65CA0F31AC8ECFB8347CC /* Pods_EasydictTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 378E73A7EA8FC8FB9C975A63 /* Pods_EasydictTests.framework */; };
B87AC7E36367075BA5D13234 /* Pods_Easydict.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6372B33DFF803C7096A82250 /* Pods_Easydict.framework */; };
C4DD01E92B12B3C80025EE8E /* TencentService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DD01E82B12B3C80025EE8E /* TencentService.swift */; };
Expand Down Expand Up @@ -709,6 +710,8 @@
62ED29A12B15F1F500901F51 /* EZWrapView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZWrapView.m; sourceTree = "<group>"; };
6372B33DFF803C7096A82250 /* Pods_Easydict.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Easydict.framework; sourceTree = BUILT_PRODUCTS_DIR; };
91E3E579C6DB88658B4BB102 /* Pods-Easydict.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Easydict.release.xcconfig"; path = "Target Support Files/Pods-Easydict/Pods-Easydict.release.xcconfig"; sourceTree = "<group>"; };
9672D7D02B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MASShortcutBinder+EZMASShortcutBinder.h"; sourceTree = "<group>"; };
9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MASShortcutBinder+EZMASShortcutBinder.m"; sourceTree = "<group>"; };
A230E9A2358C7FBC7FB26189 /* Pods-EasydictTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EasydictTests.debug.xcconfig"; path = "Target Support Files/Pods-EasydictTests/Pods-EasydictTests.debug.xcconfig"; sourceTree = "<group>"; };
C4DD01E82B12B3C80025EE8E /* TencentService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentService.swift; sourceTree = "<group>"; };
C4DD01EA2B12BA250025EE8E /* TencentResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentResponse.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1228,6 +1231,8 @@
children = (
03F25CB129327BC200E66A12 /* EZShortcut.h */,
03F25CB229327BC200E66A12 /* EZShortcut.m */,
9672D7D02B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.h */,
9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */,
);
path = Shortcut;
sourceTree = "<group>";
Expand Down Expand Up @@ -2488,6 +2493,7 @@
03B0230129231FA6001C7E63 /* EZQueryView.m in Sources */,
03542A3D2937AF4F00C34C33 /* EZQueryResult.m in Sources */,
03262C1F29EF8EE500EFECA0 /* EZPrivacyViewController.m in Sources */,
9672D7D22B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m in Sources */,
03BDA7BF2A26DA280079D04F /* NSScanner+EscapedScanning.m in Sources */,
03542A4C2937B5F100C34C33 /* EZYoudaoTranslate.m in Sources */,
037852B329583F5200D0E2CF /* EZServiceCell.m in Sources */,
Expand Down
11 changes: 6 additions & 5 deletions Easydict/Feature/Shortcut/EZShortcut.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "EZShortcut.h"
#import "EZWindowManager.h"
#import "MASShortcutBinder+EZMASShortcutBinder.h"

@implementation EZShortcut

Expand Down Expand Up @@ -48,23 +49,23 @@ + (void)setup {
[[MASShortcutBinder sharedBinder] setBindingOptions:@{NSValueTransformerNameBindingOption: NSSecureUnarchiveFromDataTransformerName}];
*/

[[MASShortcutBinder sharedBinder] bindShortcutWithDefaultsKey:EZSelectionShortcutKey toAction:^{
[[MASShortcutBinder sharedBinder] ez_bindShortcutWithDefaultsKey:EZSelectionShortcutKey toAction:^{
[windowManager selectTextTranslate];
}];

[[MASShortcutBinder sharedBinder] bindShortcutWithDefaultsKey:EZSnipShortcutKey toAction:^{
[[MASShortcutBinder sharedBinder] ez_bindShortcutWithDefaultsKey:EZSnipShortcutKey toAction:^{
[windowManager snipTranslate];
}];

[[MASShortcutBinder sharedBinder] bindShortcutWithDefaultsKey:EZInputShortcutKey toAction:^{
[[MASShortcutBinder sharedBinder] ez_bindShortcutWithDefaultsKey:EZInputShortcutKey toAction:^{
[windowManager inputTranslate];
}];

[[MASShortcutBinder sharedBinder] bindShortcutWithDefaultsKey:EZShowMiniShortcutKey toAction:^{
[[MASShortcutBinder sharedBinder] ez_bindShortcutWithDefaultsKey:EZShowMiniShortcutKey toAction:^{
[windowManager showMiniFloatingWindow];
}];

[[MASShortcutBinder sharedBinder] bindShortcutWithDefaultsKey:EZScreenshotOCRShortcutKey toAction:^{
[[MASShortcutBinder sharedBinder] ez_bindShortcutWithDefaultsKey:EZScreenshotOCRShortcutKey toAction:^{
[windowManager screenshotOCR];
}];

Expand Down
18 changes: 18 additions & 0 deletions Easydict/Feature/Shortcut/MASShortcutBinder+EZMASShortcutBinder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// MASShortcutBinder+EZMASShortcutBinder.h
// Easydict
//
// Created by Sharker on 2023/12/30.
// Copyright © 2023 izual. All rights reserved.
//

@import MASShortcut;

NS_ASSUME_NONNULL_BEGIN

@interface MASShortcutBinder (EZMASShortcutBinder)
// hidden pop button when user playing shortcut
- (void)ez_bindShortcutWithDefaultsKey: (NSString*) defaultsKeyName toAction: (dispatch_block_t) action;
@end

NS_ASSUME_NONNULL_END
18 changes: 18 additions & 0 deletions Easydict/Feature/Shortcut/MASShortcutBinder+EZMASShortcutBinder.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// MASShortcutBinder+EZMASShortcutBinder.m
// Easydict
//
// Created by Sharker on 2023/12/30.
// Copyright © 2023 izual. All rights reserved.
//

#import "MASShortcutBinder+EZMASShortcutBinder.h"
#import "EZWindowManager.h"

@implementation MASShortcutBinder (EZMASShortcutBinder)
- (void)ez_bindShortcutWithDefaultsKey:(NSString *)defaultsKeyName toAction:(dispatch_block_t)action {
EZWindowManager *windowManager = [EZWindowManager shared];
[windowManager.popButtonWindow close];
[self bindShortcutWithDefaultsKey:defaultsKeyName toAction:action];
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,7 @@ - (void)setupEventMonitor {
}];

[self.eventMonitor setDoubleCommandBlock:^{
NSLog(@"double command");

// TODO: Let users customize double-click shortcuts later on
#if DEBUG
mm_strongify(self);
[self showMiniFloatingWindow];
#endif
NSLog(@"double command block");
}];
}

Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org' do
gem 'cocoapods', '1.14.2'
end
107 changes: 107 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
rexml
activesupport (7.1.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
bigdecimal (3.1.5)
claide (1.1.0)
cocoapods (1.14.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
drb (2.2.0)
ruby2_keywords
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.16.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.7.1)
minitest (5.20.0)
molinillo (0.8.0)
mutex_m (0.2.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.7)
rexml (3.2.6)
ruby-macho (2.5.1)
ruby2_keywords (0.0.5)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.23.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)

PLATFORMS
arm64-darwin-22

DEPENDENCIES
cocoapods (= 1.14.2)!

BUNDLED WITH
2.2.3
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ target 'Easydict' do
pod 'MJExtension', '~> 3.2.1'
pod 'Masonry', '~> 1.1.0'
pod 'ReactiveObjC', '~> 3.1.1'
pod 'MASShortcut', '~> 2.4.0'
pod 'MASShortcut', :git => '[email protected]:AkaShark/MASShortcut.git', :branch => 'double_click_modifier'
pod 'MASPreferences', '~> 1.4.1'
pod 'CocoaLumberjack/Swift', '~> 3.6.0'
pod 'SSZipArchive', '~> 2.2.2'
Expand All @@ -34,7 +34,7 @@ target 'EasydictTests' do
pod 'MJExtension', '~> 3.2.1'
pod 'Masonry', '~> 1.1.0'
pod 'ReactiveObjC', '~> 3.1.1'
pod 'MASShortcut', '~> 2.4.0'
pod 'MASShortcut', :git => '[email protected]:AkaShark/MASShortcut.git', :branch => 'double_click_modifier'
pod 'MASPreferences', '~> 1.4.1'
pod 'CocoaLumberjack/Swift', '~> 3.6.0'
pod 'SSZipArchive', '~> 2.2.2'
Expand Down
15 changes: 12 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ DEPENDENCIES:
- KVOController (~> 1.2.0)
- Masonry (~> 1.1.0)
- MASPreferences (~> 1.4.1)
- MASShortcut (~> 2.4.0)
- "MASShortcut (from `[email protected]:AkaShark/MASShortcut.git`, branch `double_click_modifier`)"
- MJExtension (~> 3.2.1)
- ReactiveObjC (~> 3.1.1)
- Sparkle (~> 2.5.1)
Expand All @@ -139,7 +139,6 @@ SPEC REPOS:
- KVOController
- Masonry
- MASPreferences
- MASShortcut
- MJExtension
- nanopb
- PromisesObjC
Expand All @@ -148,6 +147,16 @@ SPEC REPOS:
- SSZipArchive
- SwiftFormat

EXTERNAL SOURCES:
MASShortcut:
:branch: double_click_modifier
:git: "[email protected]:AkaShark/MASShortcut.git"

CHECKOUT OPTIONS:
MASShortcut:
:commit: 694922e088bc91eb70eff42ddaf7602c5b87f1f1
:git: "[email protected]:AkaShark/MASShortcut.git"

SPEC CHECKSUMS:
AFNetworking: cb604b1c2bded0871f5f61f5d53653739e841d6b
AppCenter: 85c92db0759d2792a65eb61d6842d2e86611a49a
Expand All @@ -171,6 +180,6 @@ SPEC CHECKSUMS:
SSZipArchive: 62d4947b08730e4cda640473b0066d209ff033c9
SwiftFormat: 2ca3d0b75754193f0f3ba532291f25ae08dd1e42

PODFILE CHECKSUM: a35287f08d36ebe90dd9f3362e15bf7aaeeaf0f5
PODFILE CHECKSUM: 597cd2d7aa9ead11dfe63d03ada0bdffc6ee7ad8

COCOAPODS: 1.14.2
32 changes: 32 additions & 0 deletions Pods/Local Podspecs/MASShortcut.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Pods/MASShortcut/Framework/Model/MASShortcut.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions Pods/MASShortcut/Framework/Model/MASShortcut.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading