Skip to content

Commit

Permalink
Revert "Revert "Feautre tips view (tisfeng#418)" (tisfeng#477)"
Browse files Browse the repository at this point in the history
This reverts commit 11fd868.
  • Loading branch information
AkaShark committed Apr 1, 2024
1 parent c337936 commit 91ad693
Show file tree
Hide file tree
Showing 17 changed files with 617 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
9672D7D22B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m in Sources */ = {isa = PBXBuildFile; fileRef = 9672D7D12B4008B40023B8FB /* MASShortcutBinder+EZMASShortcutBinder.m */; };
967712EA2B5B913600105E0F /* KeyHolder in Frameworks */ = {isa = PBXBuildFile; productRef = 967712E92B5B913600105E0F /* KeyHolder */; };
967712EE2B5B943400105E0F /* Shortcut.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967712ED2B5B943400105E0F /* Shortcut.swift */; };
96DFEB832B82588000F5C7EF /* EZTableTipsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 96DFEB822B82588000F5C7EF /* EZTableTipsCell.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 */; };
C415C0AD2B450D4800A9D231 /* GeminiService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415C0AC2B450D4800A9D231 /* GeminiService.swift */; };
Expand Down Expand Up @@ -825,6 +826,8 @@
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>"; };
967712ED2B5B943400105E0F /* Shortcut.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shortcut.swift; sourceTree = "<group>"; };
96DFEB812B82588000F5C7EF /* EZTableTipsCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZTableTipsCell.h; sourceTree = "<group>"; };
96DFEB822B82588000F5C7EF /* EZTableTipsCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZTableTipsCell.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>"; };
C415C0AC2B450D4800A9D231 /* GeminiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeminiService.swift; sourceTree = "<group>"; };
C4DD01E82B12B3C80025EE8E /* TencentService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1502,6 +1505,8 @@
children = (
0396D60F292C932F006A11D9 /* EZSelectLanguageCell.h */,
0396D610292C932F006A11D9 /* EZSelectLanguageCell.m */,
96DFEB812B82588000F5C7EF /* EZTableTipsCell.h */,
96DFEB822B82588000F5C7EF /* EZTableTipsCell.m */,
037852B7295D49F900D0E2CF /* EZTableRowView.h */,
037852B8295D49F900D0E2CF /* EZTableRowView.m */,
);
Expand Down Expand Up @@ -3008,6 +3013,7 @@
03B022FE29231FA6001C7E63 /* EZBaseQueryViewController.m in Sources */,
DC6D9C892B3969510055EFFC /* Appearance.swift in Sources */,
0396D611292C932F006A11D9 /* EZSelectLanguageCell.m in Sources */,
96DFEB832B82588000F5C7EF /* EZTableTipsCell.m in Sources */,
036196752A000F5900806370 /* FWEncryptorAES.m in Sources */,
9643D9462B71D103000FBEA6 /* KeyHolderRowView.swift in Sources */,
0399C6A829A74E0F00B4AFCC /* EZQueryResult+EZDeepLTranslateResponse.m in Sources */,
Expand Down
22 changes: 22 additions & 0 deletions Easydict/App/Assets.xcassets/tip_Normal.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "tip_Normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "tip_Normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
203 changes: 203 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,23 @@
}
}
},
"disable_tips_view" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Disable Tips View"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "关闭提示视图"
}
}
}
},
"disabled_app_list" : {
"comment" : "disabled app list",
"localizations" : {
Expand Down Expand Up @@ -4281,6 +4298,192 @@
}
}
},
"tips_beep" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why is there a beep when the selected word is empty (such as dragging in a blank area) in some applications?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么在某些应用取词为空(空白处拖动等)时会出现提示音?"
}
}
}
},
"tips_edit_button" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why does the edit button in the upper right corner flicker when selecting words in some applications?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么在某些应用取词时,右上角编辑按钮会出现闪烁?"
}
}
}
},
"tips_might_selecting" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why might selecting an empty word interrupt the music currently playing?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么取词为空时可能打断当前播放的音乐?"
}
}
}
},
"tips_more" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "See More"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "查看更多"
}
}
}
},
"tips_mouse_hover" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why can't I use mouse hover to select words in some applications?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么在某些应用中无法使用鼠标划词?"
}
}
}
},
"tips_select_words" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why can't I select words on some web pages in the browser?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么浏览器中某些网页无法取词?"
}
}
}
},
"tips_solve" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Solve This"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "如何解决"
}
}
}
},
"tips_still_pop_up" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why does macOS still pop up asking for permissions even though I have given Easydict the Accessibility/Screen Recording permissions?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "已经给 Easydict 辅助功能/录屏权限 macOS 仍然弹窗要求给予权限?"
}
}
}
},
"tips_text_empty" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why is the text empty when I select words in some applications?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么在某些应用中取词文本为空?"
}
}
}
},
"tips_title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tips"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "提示"
}
}
}
},
"tips_word_selection_OCR" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Why do word selection and OCR need to enable system-related permissions?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "为什么取词和 OCR 需要开启系统相关权限?"
}
}
}
},
"Tisfeng" : {
"localizations" : {
"zh-Hans" : {
Expand Down
2 changes: 2 additions & 0 deletions Easydict/Feature/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class Configuration: NSObject {

@DefaultsWrapper(.selectQueryTextWhenWindowActivate) var selectQueryTextWhenWindowActivate: Bool

@DefaultsWrapper(.disableTipsView) var disableTipsView: Bool

var disabledAutoSelect: Bool = false

var isRecordingSelectTextShortcutKey: Bool = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ static NSArray *const EZDashCharacterList = @[ @"—", @"-", @"–" ];

- (NSString *)removeAlphabetAndNumbers;

#pragma mark - Check Empty String
#ifndef EZ_isEmptyString
FOUNDATION_EXPORT BOOL EZ_isEmptyString(id param);
#endif

@end

NS_ASSUME_NONNULL_END
17 changes: 15 additions & 2 deletions Easydict/Feature/Utility/EZCategory/NSString/NSString+EZUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
@"" : @"",
};

BOOL EZ_isEmptyString(id param) {
if (!param) {
return YES;
}
if ([param isKindOfClass:[NSString class]]) {
NSString *str = param;
return (str.length == 0);
}
NSCAssert(NO, @"isEmptyString: param %@ is not NSString", param);
return YES;
}


@implementation NSString (EZUtils)

/// Check if it is a single letter of the alphabet, like 'a', 'A'
Expand Down Expand Up @@ -224,7 +237,7 @@ - (BOOL)isEnglishWordWithLanguage:(EZLanguage)language {
}

- (NLLanguage)detectText {
NLTagger *tagger = [[NLTagger alloc] initWithTagSchemes:@[NLTagSchemeLanguage]];
NLTagger *tagger = [[NLTagger alloc] initWithTagSchemes:@[ NLTagSchemeLanguage ]];
tagger.string = self;
NLLanguage language = [tagger dominantLanguage];
return language;
Expand Down Expand Up @@ -466,7 +479,7 @@ - (NSString *)suffixQuote {
}
return quotes;
}


- (NSString *)tryToRemovePrefixQuote {
NSString *prefixQuote = [self prefixQuote];
Expand Down
19 changes: 19 additions & 0 deletions Easydict/Feature/ViewController/Cell/EZTableTipsCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// EZTableTipsCell.h
// Easydict
//
// Created by Sharker on 2024/2/18.
// Copyright © 2024 izual. All rights reserved.
//

#import <Cocoa/Cocoa.h>

NS_ASSUME_NONNULL_BEGIN

@interface EZTableTipsCell : NSTableRowView

- (CGFloat)cellHeight;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 91ad693

Please sign in to comment.