diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index a1e5d3696..3319666f9 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -256,6 +256,10 @@ 62E2BF4C2B4082BA00E42D38 /* AliTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E2BF492B4082BA00E42D38 /* AliTranslateType.swift */; }; 62ED29A22B15F1F500901F51 /* EZWrapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 62ED29A12B15F1F500901F51 /* EZWrapView.m */; }; 9672D7D22B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m in Sources */ = {isa = PBXBuildFile; fileRef = 9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */; }; + 969885D32B564041005C8ECB /* KeyHolder in Frameworks */ = {isa = PBXBuildFile; productRef = 969885D22B564041005C8ECB /* KeyHolder */; }; + 969885D92B5640BB005C8ECB /* GeneralShortcutSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 969885D62B5640BB005C8ECB /* GeneralShortcutSetting.swift */; }; + 969885DA2B5640BB005C8ECB /* GeneralKeyHolderWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 969885D72B5640BB005C8ECB /* GeneralKeyHolderWrapper.swift */; }; + 969885DB2B5640BB005C8ECB /* GeneralOtherSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 969885D82B5640BB005C8ECB /* GeneralOtherSetting.swift */; }; 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 */; }; @@ -745,6 +749,9 @@ 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 = ""; }; 9672D7D02B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MASShortcutBinder+EZMASShortcutBinder.h"; sourceTree = ""; }; 9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MASShortcutBinder+EZMASShortcutBinder.m"; sourceTree = ""; }; + 969885D62B5640BB005C8ECB /* GeneralShortcutSetting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralShortcutSetting.swift; sourceTree = ""; }; + 969885D72B5640BB005C8ECB /* GeneralKeyHolderWrapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralKeyHolderWrapper.swift; sourceTree = ""; }; + 969885D82B5640BB005C8ECB /* GeneralOtherSetting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralOtherSetting.swift; sourceTree = ""; }; 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 = ""; }; C4DD01E82B12B3C80025EE8E /* TencentService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentService.swift; sourceTree = ""; }; C4DD01EA2B12BA250025EE8E /* TencentResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentResponse.swift; sourceTree = ""; }; @@ -806,6 +813,7 @@ EA3B81FC2B52555C004C0E8B /* Defaults in Frameworks */, 03CF27FE2B3DA7D500E19B57 /* Realm in Frameworks */, 03A830902B4073E700112834 /* AppCenterAnalytics in Frameworks */, + 969885D32B564041005C8ECB /* KeyHolder in Frameworks */, 03B63ABF2A86967800E155ED /* CoreServices.framework in Frameworks */, 038030972B4106800009230C /* CocoaLumberjackSwift in Frameworks */, 038EA1AA2B41169C008A6DD1 /* ZipArchive in Frameworks */, @@ -2072,6 +2080,7 @@ 27FE980C2B3DD749000AD654 /* Tabs */ = { isa = PBXGroup; children = ( + 969885D42B5640BA005C8ECB /* View */, 278540332B3DE04F004E9488 /* GeneralTab.swift */, 0A057D6C2B499A000025C51D /* ServiceTab.swift */, 276742042B3DC230002A2C75 /* PrivacyTab.swift */, @@ -2128,6 +2137,24 @@ name = Frameworks; sourceTree = ""; }; + 969885D42B5640BA005C8ECB /* View */ = { + isa = PBXGroup; + children = ( + 969885D52B5640BB005C8ECB /* Genearl */, + ); + path = View; + sourceTree = ""; + }; + 969885D52B5640BB005C8ECB /* Genearl */ = { + isa = PBXGroup; + children = ( + 969885D62B5640BB005C8ECB /* GeneralShortcutSetting.swift */, + 969885D72B5640BB005C8ECB /* GeneralKeyHolderWrapper.swift */, + 969885D82B5640BB005C8ECB /* GeneralOtherSetting.swift */, + ); + path = Genearl; + sourceTree = ""; + }; 9CB57B9B45EC322A11ED8865 /* Pods */ = { isa = PBXGroup; children = ( @@ -2321,6 +2348,7 @@ 038EA1A92B41169C008A6DD1 /* ZipArchive */, 038EA1AC2B41282F008A6DD1 /* MJExtension */, EA3B81FB2B52555C004C0E8B /* Defaults */, + 969885D22B564041005C8ECB /* KeyHolder */, ); productName = Bob; productReference = C99EEB182385796700FEE666 /* Easydict-debug.app */; @@ -2380,6 +2408,7 @@ 038EA1A82B41169C008A6DD1 /* XCRemoteSwiftPackageReference "ZipArchive" */, 038EA1AB2B41282F008A6DD1 /* XCRemoteSwiftPackageReference "MJExtension" */, EA3B81FA2B52555C004C0E8B /* XCRemoteSwiftPackageReference "Defaults" */, + 969885D12B564040005C8ECB /* XCRemoteSwiftPackageReference "KeyHolder" */, ); productRefGroup = C99EEB192385796700FEE666 /* Products */; projectDirPath = ""; @@ -2651,6 +2680,7 @@ 03542A432937B45E00C34C33 /* EZBaiduTranslate.m in Sources */, 03BB2DEB29F57DC000447EDD /* NSImage+EZSymbolmage.m in Sources */, 03B0230629231FA6001C7E63 /* EZLabel.m in Sources */, + 969885DA2B5640BB005C8ECB /* GeneralKeyHolderWrapper.swift in Sources */, 03F25CB329327BC200E66A12 /* EZShortcut.m in Sources */, 033B7134293CE2430096E2DF /* EZWebViewTranslator.m in Sources */, 03CF88632B137F650030C199 /* Array+Convenience.swift in Sources */, @@ -2702,6 +2732,7 @@ 03BB2DEF29F59C8A00447EDD /* EZSymbolImageButton.m in Sources */, 0A2BA9642B4A3CCD002872A4 /* Notification+Name.swift in Sources */, 62A2D03F2A82967F007EEB01 /* EZBingRequest.m in Sources */, + 969885D92B5640BB005C8ECB /* GeneralShortcutSetting.swift in Sources */, 03BDA7BE2A26DA280079D04F /* XPMCountedArgument.m in Sources */, 03D35DAA2AA6C49B00B023FE /* NSString+EZRegex.m in Sources */, 03B022FE29231FA6001C7E63 /* EZBaseQueryViewController.m in Sources */, @@ -2775,6 +2806,7 @@ 037852B02957FEB200D0E2CF /* EZServiceViewController.m in Sources */, 6220AD5B2A82812300BBFB52 /* EZBingService.m in Sources */, 039F5508294B6E29004AB940 /* EZAboutViewController.m in Sources */, + 969885DB2B5640BB005C8ECB /* GeneralOtherSetting.swift in Sources */, 03D8A6592A42A1A300D9A968 /* EZAppModel.m in Sources */, 036E7D7B293F4FC8002675DF /* EZOpenLinkButton.m in Sources */, 276742092B3DC230002A2C75 /* AboutTab.swift in Sources */, @@ -3351,6 +3383,14 @@ minimumVersion = 5.8.1; }; }; + 969885D12B564040005C8ECB /* XCRemoteSwiftPackageReference "KeyHolder" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Clipy/KeyHolder.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 4.2.0; + }; + }; EA3B81FA2B52555C004C0E8B /* XCRemoteSwiftPackageReference "Defaults" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/sindresorhus/Defaults.git"; @@ -3437,6 +3477,11 @@ package = 2721E4CE2AFE920700A059AC /* XCRemoteSwiftPackageReference "Alamofire" */; productName = Alamofire; }; + 969885D22B564041005C8ECB /* KeyHolder */ = { + isa = XCSwiftPackageProductDependency; + package = 969885D12B564040005C8ECB /* XCRemoteSwiftPackageReference "KeyHolder" */; + productName = KeyHolder; + }; EA3B81FB2B52555C004C0E8B /* Defaults */ = { isa = XCSwiftPackageProductDependency; package = EA3B81FA2B52555C004C0E8B /* XCRemoteSwiftPackageReference "Defaults" */; diff --git a/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved index 38cf97c19..6f0e3dd33 100644 --- a/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -12,7 +12,7 @@ { "identity" : "alamofire", "kind" : "remoteSourceControl", - "location" : "https://github.com/Alamofire/Alamofire", + "location" : "https://github.com/Alamofire/Alamofire.git", "state" : { "revision" : "3dc6a42c7727c49bf26508e29b0a0b35f9c7e1ad", "version" : "5.8.1" @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/krzyzanowskim/CryptoSwift", "state" : { - "revision" : "db51c407d3be4a051484a141bf0bff36c43d3b1e", - "version" : "1.8.0" + "revision" : "7892a123f7e8d0fe62f9f03728b17bbd4f94df5c", + "version" : "1.8.1" } }, { @@ -135,6 +135,15 @@ "version" : "100.0.0" } }, + { + "identity" : "keyholder", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Clipy/KeyHolder.git", + "state" : { + "revision" : "5da0ee06fd8709f7d812504bff1555462a3f6956", + "version" : "4.2.0" + } + }, { "identity" : "leveldb", "kind" : "remoteSourceControl", @@ -144,6 +153,15 @@ "version" : "1.22.3" } }, + { + "identity" : "magnet", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Clipy/Magnet", + "state" : { + "revision" : "26d672a031fd33eac94887b4e19aca0ab4761f45", + "version" : "3.4.0" + } + }, { "identity" : "mjextension", "kind" : "remoteSourceControl", @@ -198,13 +216,22 @@ "version" : "10.45.2" } }, + { + "identity" : "sauce", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Clipy/Sauce", + "state" : { + "revision" : "8f8fabaa8509c1a653d6c2c3c87396a4c493d876", + "version" : "2.4.0" + } + }, { "identity" : "snapkit", "kind" : "remoteSourceControl", "location" : "https://github.com/SnapKit/SnapKit", "state" : { - "revision" : "f222cbdf325885926566172f6f5f06af95473158", - "version" : "5.6.0" + "revision" : "e74fe2a978d1216c3602b129447c7301573cc2d8", + "version" : "5.7.0" } }, { diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index c75689b1e..4a4fe4a4b 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -2849,6 +2849,23 @@ } } }, + "shortcut_setting" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Shortcut Setting" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "快捷键设置" + } + } + } + }, "show" : { "localizations" : { "en" : { diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralKeyHolderWrapper.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralKeyHolderWrapper.swift new file mode 100644 index 000000000..66b1186b0 --- /dev/null +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralKeyHolderWrapper.swift @@ -0,0 +1,45 @@ +// +// GeneralKeyHolderWrapper.swift +// Easydict +// +// Created by Sharker on 2024/1/2. +// Copyright © 2024 izual. All rights reserved. +// + +import AppKit +import KeyHolder +import Magnet +import SwiftUI + +struct GeneralKeyHolderWrapper: NSViewRepresentable { + func makeCoordinator() -> Coordinator { + .init() + } + + func makeNSView(context: Context) -> some NSView { + let recordView = RecordView(frame: CGRect.zero) + recordView.tintColor = NSColor(red: 0.164, green: 0.517, blue: 0.823, alpha: 1) + recordView.delegate = context.coordinator + recordView.layer?.cornerRadius = 6.0 + recordView.layer?.masksToBounds = true + return recordView + } + + func updateNSView(_: NSViewType, context _: Context) {} +} + +extension GeneralKeyHolderWrapper { + class Coordinator: NSObject, RecordViewDelegate { + func recordViewShouldBeginRecording(_: KeyHolder.RecordView) -> Bool { + true + } + + func recordView(_: KeyHolder.RecordView, canRecordKeyCombo _: Magnet.KeyCombo) -> Bool { + true + } + + func recordView(_: KeyHolder.RecordView, didChangeKeyCombo _: Magnet.KeyCombo?) {} + + func recordViewDidEndRecording(_: KeyHolder.RecordView) {} + } +} diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralOtherSetting.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralOtherSetting.swift new file mode 100644 index 000000000..c3abe9498 --- /dev/null +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralOtherSetting.swift @@ -0,0 +1,50 @@ +// +// GeneralOtherSetting.swift +// Easydict +// +// Created by Sharker on 2024/1/1. +// Copyright © 2024 izual. All rights reserved. +// + +import SwiftUI + +@available(macOS 13.0, *) +extension GeneralTab { + struct OtherSettingView: View { + var body: some View { + Section { + HStack { + Text("show_main_window") + Toggle(isOn: $hideMainWindow) { + Text("hide_main_window") + } + } + HStack { + Text("launch") + Toggle(isOn: $launchAtStartup) { + Text("launch_at_startup") + } + } + HStack { + Text("menu_bar_icon") + Toggle(isOn: $hideMenuBarIcon) { + Text("hide_menu_bar_icon") + } + } + HStack { + Text("beta_new_app") + Toggle(isOn: $enableBetaNewApp) { + Text("enable_beta_new_app") + } + } + } header: { + Text("other") + } + } + + @AppStorage(kHideMainWindowKey) private var hideMainWindow = false + @AppStorage(kLaunchAtStartupKey) private var launchAtStartup = false + @AppStorage(kHideMenuBarIconKey) private var hideMenuBarIcon = false + @AppStorage(kEnableBetaNewAppKey) private var enableBetaNewApp = false + } +} diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralShortcutSetting.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralShortcutSetting.swift new file mode 100644 index 000000000..733177aab --- /dev/null +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Genearl/GeneralShortcutSetting.swift @@ -0,0 +1,37 @@ +// +// GeneralShortcutSetting.swift +// Easydict +// +// Created by Sharker on 2024/1/1. +// Copyright © 2024 izual. All rights reserved. +// + +import SwiftUI + +@available(macOS 13, *) +extension GeneralTab { + struct ShortcutSettingView: View { + var body: some View { + Section { + HStack { + Text("input_translate") + GeneralKeyHolderWrapper() + } + HStack { + Text("snip_translate") + GeneralKeyHolderWrapper() + } + HStack { + Text("select_translate") + GeneralKeyHolderWrapper() + } + HStack { + Text("silent_screenshot_ocr") + GeneralKeyHolderWrapper() + } + } header: { + Text("shortcut_setting") + } + } + } +}