From 91ad6930ecd7fab583555594d9f33ebaf1eec79e Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Mon, 1 Apr 2024 20:48:43 +0800 Subject: [PATCH 01/24] Revert "Revert "Feautre tips view (#418)" (#477)" This reverts commit 11fd8685deefb4515ddc495294346ff7b1e7907b. --- Easydict.xcodeproj/project.pbxproj | 6 + .../tip_Normal.imageset/Contents.json | 22 ++ .../tip_Normal.imageset/tip_Normal.png | Bin 0 -> 907 bytes .../tip_Normal.imageset/tip_Normal@2x.png | Bin 0 -> 2088 bytes Easydict/App/Localizable.xcstrings | 203 +++++++++++++ .../Feature/Configuration/Configuration.swift | 2 + .../EZCategory/NSString/NSString+EZUtils.h | 5 + .../EZCategory/NSString/NSString+EZUtils.m | 17 +- .../ViewController/Cell/EZTableTipsCell.h | 19 ++ .../ViewController/Cell/EZTableTipsCell.m | 266 ++++++++++++++++++ .../View/CustomButton/EZButton/EZButton.h | 2 + .../View/CustomButton/EZButton/EZButton.m | 6 + .../EZBaseQueryViewController.h | 1 + .../EZBaseQueryViewController.m | 64 ++++- .../Window/WindowManager/EZWindowManager.m | 5 +- .../Configuration+Defaults.swift | 2 + .../View/SettingView/Tabs/AdvancedTab.swift | 5 +- 17 files changed, 617 insertions(+), 8 deletions(-) create mode 100644 Easydict/App/Assets.xcassets/tip_Normal.imageset/Contents.json create mode 100644 Easydict/App/Assets.xcassets/tip_Normal.imageset/tip_Normal.png create mode 100644 Easydict/App/Assets.xcassets/tip_Normal.imageset/tip_Normal@2x.png create mode 100644 Easydict/Feature/ViewController/Cell/EZTableTipsCell.h create mode 100644 Easydict/Feature/ViewController/Cell/EZTableTipsCell.m diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 900cdfece..cded438e9 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -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 */; }; @@ -825,6 +826,8 @@ 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 = ""; }; 967712ED2B5B943400105E0F /* Shortcut.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shortcut.swift; sourceTree = ""; }; + 96DFEB812B82588000F5C7EF /* EZTableTipsCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EZTableTipsCell.h; sourceTree = ""; }; + 96DFEB822B82588000F5C7EF /* EZTableTipsCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EZTableTipsCell.m; 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 = ""; }; C415C0AC2B450D4800A9D231 /* GeminiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeminiService.swift; sourceTree = ""; }; C4DD01E82B12B3C80025EE8E /* TencentService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TencentService.swift; sourceTree = ""; }; @@ -1502,6 +1505,8 @@ children = ( 0396D60F292C932F006A11D9 /* EZSelectLanguageCell.h */, 0396D610292C932F006A11D9 /* EZSelectLanguageCell.m */, + 96DFEB812B82588000F5C7EF /* EZTableTipsCell.h */, + 96DFEB822B82588000F5C7EF /* EZTableTipsCell.m */, 037852B7295D49F900D0E2CF /* EZTableRowView.h */, 037852B8295D49F900D0E2CF /* EZTableRowView.m */, ); @@ -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 */, diff --git a/Easydict/App/Assets.xcassets/tip_Normal.imageset/Contents.json b/Easydict/App/Assets.xcassets/tip_Normal.imageset/Contents.json new file mode 100644 index 000000000..f008b3dac --- /dev/null +++ b/Easydict/App/Assets.xcassets/tip_Normal.imageset/Contents.json @@ -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 + } +} diff --git a/Easydict/App/Assets.xcassets/tip_Normal.imageset/tip_Normal.png b/Easydict/App/Assets.xcassets/tip_Normal.imageset/tip_Normal.png new file mode 100644 index 0000000000000000000000000000000000000000..b424c640e5254e7028b2e1cc3d9851aa73ae04ac GIT binary patch literal 907 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~m(&Q)G+$o^ zEg+kNfw4W4fd!-lh^2s-fq{7eBLg##W(0{XV1mnvEMP{kK?*nB{qUE8f$6KKi(`m| z;L;FpAK^d|TjRM49R#|ax*HlbrOL#XsA_SSX7;QzxY{8t?0F}-amDFJWqa_Qx<{&>GHys++*Xo_gQ>J!})Hjjd1@*foj)iiP*Ql0qmQ_zFv3G+i$ zJCc?*eq8hLmt}HqP06=D1uk~W%j=JQZvDaZbl#r1J16C2>*`OmS>AV2Bgo~1((wlu zgyihgU%Z(1Yimc{p86y`f%E?$|;RMT07gKesPd}q&# ziFmguYsT`NnC|O#+gEqrxj65lk#b{{!Pm{5u@X0S2vmDX`N{D%Z#c@z=f3jMo6kGv zo@Fs(y?NqHqV1V;Yi@qOFt4ywAnL)gmwA~UE!$GooUO?42okzeY1KM!U;aUb{tsMc zHjmA#zZkWurR@*$Y35^yDE+$l`i$O^U3c5I*z(M5Uy)wYI^(q*xB0^);}80W8$*Qz zjlC?&en_}jAO99~S#+x43_*tou>sclYM)HiZ!h*wuv5Fv2a4ya@mt}HpFdz-57pSues&(3C1qa?%slQh7gJJH5*0i>IktKd7-<^@M^yIR*bTIW~+9Rb|=bF0(loEBf zm;d>lvPa_SY_6cqYYb+G-(Ru#f{bnL-i)>TTg#n;XMak1-MLA}IK3wBx{1p2CA0Xq zu1ITCX{i@A`D1Qke$A0rHz}!x=e>3OrCCx!Av&$TYlYkPgTe~DWM4fT;P5# literal 0 HcmV?d00001 diff --git a/Easydict/App/Assets.xcassets/tip_Normal.imageset/tip_Normal@2x.png b/Easydict/App/Assets.xcassets/tip_Normal.imageset/tip_Normal@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a8001c97e72770a12dd0e749c5c0fafef9941b8b GIT binary patch literal 2088 zcmV+@2-o+CP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91D4+uX1ONa40RR91C;$Ke0D9(TtN;K9l1W5CR9FeMSZiz)RTMsVW_J5r z=yO|I5GheHzS6XX5MNPDd_*x(FcO3DhYE@B#GfX{M1N?E!AE=~Dxy)0MkGQi#t=o3 zV7E`8Qjm6|2;JQR+ittt-JPAeo^xlWo!y;fr?uW>_uhN%Io~~V?s?o91`E{M+Q1`S z@E-+<9SIDFA6Ot*P!z;~e%v&jnAC3_92=V|#_wi*O-ub{I%7X0ZYTQdV;7TgYr&3kAN%TJKyKGoH#gVn zob3V5n%u|~4H60XMjhC%__TL+v@~`EMnVA#xOG`wldLHBF{a-I46egXYsDJl=Yhij z=TfJZ$?WPoeeSF!qnD~17#G1bkcjc;EPA27=n<1(TT8<=2zqmOF!T=1NioGMzl1*b z2r6FWA$bNE`y`XrUL-}Ys;{psuVh;@8T|{p;)LteTq$T5>{!uo4_fPUr1?AwhqbK= z+}N(bsul@qsu(V5kep7z;Gfg*`wQR(&WC4DYey6&ueX6~F2fVPf(b^tZ|gM*G1f5tkAV#?9F?1qVWgyjHs zkaAld^uSY_OJGrD;pbz>=<$|;$HSrZ@;EGOVh}hcGfjs(nyV}O&W^`Vy4l;6g5-0O zEd7LgmXdOtHmm~A(kB4)1n|_1|2yudC?#k#fTr36G&eFh)US{q+}%)Fwj&fvOgakL zh^`b|R_}WQW!BQMKK=NWP{>W|J2WWy)xQM6J(kk2Xpjlkpz;949qk*{r>0I?wkdNPYNGbt^v z664MHB!RF9Q((_^9yfPrk|d!|mO=$2;r8n_*n2=x3~YEuq#mF2GDi7oJpLBO z;f1bX_(Ou3u^>8ijhWroabT}f#wP}mgt4boLQRi#gZkI2AbA@>iyaa)`V-bu3kMDH zcuS0n&YEjgn$BRC`=m8EeFl|Vi+uwJZkQVW$BVDhQ9);)G$Ag!NIbJ>rbJ%H_ywX} zh&gAZ@uRcWv&$+K92Q@bzdz>;RNdUx#J0=jj*DB6q8jsT@H7X%2%Bt(vL+5?O@>cR z9Frh5X1GGlY8?Y9o0rNT!w?OPnGb7VXEWu@idql>dr4+s$aL%+fbwMk)=w@o7RxW; zf|kRI$=bl^`NL4q!p`Nh&xzgj%$oQ_E;Z7VjT2eA&Ww z;Lz31mCT?c8hTk{l3gN{TI7l^+`U5mOoK+x9w1cHS&NkVoMyN zocPFkDZE*|`=t>@ghiP2mdF|3iq#9N7Q0hndfq!qUUF-$@g2dZ>e6e%k9PkNKV>OW zt&|=1l(0?bqr6(hn%j1Do~Xr|*H6cz@Xe2O{TJ2?PEYEa#u5o}=fEph&(eyjkGRZF zW6> zG&7mzWI+qKeWibk*HiL7&1>-zQCFSs%Ct6tFHE8H#sj3))Yk6d$OlB9OPiO1v;kgl zo%2b7-SJ8_uf2rV7Ql2xe*Wccj(n#^f`Y#LV@wMFq5WqC>->$5+n+c!>`0$0(b;+2 zp-d9n^fcDDoJIjcO*Sv6I262sILE*FE6Cv(?KON{bXnV`QpTkq7CmRsP2Mafmy>xb zh}GZ=+GF3hJM*jATF_+q^>G+D3ea^GKa$?Y79ao)2VH{Vq43 z*=#~t!+BefQ0Uvrl9u>KFzt)rlU8Geq4(J|7XMy6*4M~#y+ett+M2byi^;!QY`Ff! Sl5~v#0000 + +NS_ASSUME_NONNULL_BEGIN + +@interface EZTableTipsCell : NSTableRowView + +- (CGFloat)cellHeight; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m new file mode 100644 index 000000000..1d7563be5 --- /dev/null +++ b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m @@ -0,0 +1,266 @@ +// +// EZTableTipsCell.m +// Easydict +// +// Created by Sharker on 2024/2/18. +// Copyright © 2024 izual. All rights reserved. +// + +#import "EZTableTipsCell.h" +#import "EZOpenLinkButton.h" +#import "NSImage+EZSymbolmage.h" +#import "EZLanguageManager.h" + +@interface EZTableTipsCell () +@property (nonatomic, strong) NSView *contentView; +@property (nonatomic, strong) NSImageView *tipsIconImageView; +@property (nonatomic, strong) NSTextField *tipsNameLabel; +@property (nonatomic, strong) NSTextField *tipsContentLabel; +@property (nonatomic, strong) EZOpenLinkButton *moreBtn; +@property (nonatomic, strong) EZOpenLinkButton *solveBtn; +@property (nonatomic, strong) NSDictionary *dataDict; +@property (nonatomic, strong) NSString *questionSolveURL; +@property (nonatomic, strong) NSString *seeMoreURL; +@end + +@implementation EZTableTipsCell + +- (instancetype)initWithFrame:(NSRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self setupUI]; + [self updateQuestionContent]; + } + return self; +} + +- (void)setupUI { + // mas key + self.contentView.mas_key = @"topBarView"; + self.tipsIconImageView.mas_key = @"tipsIconImageView"; + self.tipsNameLabel.mas_key = @"tipsNameLabel"; + self.moreBtn.mas_key = @"moreBtn"; + self.solveBtn.mas_key = @"solveBtn"; + + CGSize iconSize = CGSizeMake(20, 20); + + // constraints + [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(0); + }]; + + [self.tipsIconImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(9); + make.top.mas_equalTo(9); + make.size.mas_equalTo(iconSize); + }]; + + [self.tipsNameLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.tipsIconImageView.mas_right).offset(6); + make.centerY.mas_equalTo(self.tipsIconImageView.mas_centerY).offset(1); + }]; + + [self.solveBtn mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(9); + make.top.mas_equalTo(self.tipsContentLabel.mas_bottom).offset(9); + make.size.mas_equalTo(CGSizeMake(98, 32)); + }]; + + [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.solveBtn.mas_right).offset(20); + make.top.mas_equalTo(self.solveBtn); + make.size.mas_equalTo(CGSizeMake(94, 32)); + }]; +} + +- (void)updateConstraints { + [self.tipsContentLabel mas_updateConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(9); + make.width.mas_lessThanOrEqualTo(self.bounds.size.width - 9); + make.top.mas_equalTo(self.tipsNameLabel.mas_bottom).offset(12); + }]; + + [super updateConstraints]; +} + +- (void)updateQuestionContent { + NSArray *questions = self.dataDict[@"questions"]; + int index = arc4random() % questions.count; + self.tipsContentLabel.stringValue = questions[index]; + NSArray *solves; + if ([EZLanguageManager.shared isSystemChineseFirstLanguage]) { + solves = self.dataDict[@"solveZh"]; + } else { + solves = self.dataDict[@"solveEn"]; + } + self.questionSolveURL = solves[index]; + self.solveBtn.link = self.questionSolveURL; +} + +- (CGFloat)cellHeight { + CGFloat cellHeight = 9 + 20 + 12 + self.tipsContentLabel.height + 9 + 32 + 6; + return cellHeight; +} + +#pragma mark - Accesstor +- (NSView *)contentView { + if (!_contentView) { + mm_weakify(self); + _contentView = [NSView mm_make:^(NSView *_Nonnull view) { + mm_strongify(self); + [self addSubview:view]; + view.wantsLayer = YES; + view.layer.cornerRadius = EZCornerRadius_8; + [view.layer excuteLight:^(CALayer *layer) { + layer.backgroundColor = [NSColor ez_titleBarBgLightColor].CGColor; + } dark:^(CALayer *layer) { + layer.backgroundColor = [NSColor ez_titleBarBgDarkColor].CGColor; + }]; + }]; + } + return _contentView; +} + +- (NSImageView *)tipsIconImageView { + if (!_tipsIconImageView) { + mm_weakify(self); + _tipsIconImageView = [NSImageView mm_make:^(NSImageView *imageView) { + mm_strongify(self); + [self.contentView addSubview:imageView]; + [imageView setImage:[NSImage imageNamed:@"tip_Normal"]]; + }]; + } + return _tipsIconImageView; +} + +- (NSTextField *)tipsNameLabel { + if (!_tipsNameLabel) { + mm_weakify(self); + _tipsNameLabel = [NSTextField mm_make:^(NSTextField *label) { + mm_strongify(self); + [self.contentView addSubview:label]; + label.stringValue = NSLocalizedString(@"tips_title", nil); + label.editable = NO; + label.bordered = NO; + label.backgroundColor = NSColor.clearColor; + label.alignment = NSTextAlignmentCenter; + label.font = [NSFont systemFontOfSize:14]; + [label excuteLight:^(NSTextField *label) { + label.textColor = [NSColor ez_resultTextLightColor]; + } dark:^(NSTextField *label) { + label.textColor = [NSColor ez_resultTextDarkColor]; + }]; + }]; + } + return _tipsNameLabel; +} + +- (NSTextField *)tipsContentLabel { + if (!_tipsContentLabel) { + mm_weakify(self); + _tipsContentLabel = [NSTextField mm_make:^(NSTextField *label) { + mm_strongify(self); + [self.contentView addSubview:label]; + label.editable = NO; + label.bordered = NO; + label.backgroundColor = NSColor.clearColor; + label.alignment = NSTextAlignmentLeft; + label.stringValue = self.dataDict[@"questions"][0]; + label.usesSingleLineMode = NO; + label.maximumNumberOfLines = 0; + [label excuteLight:^(NSTextField *label) { + label.textColor = [NSColor ez_resultTextLightColor]; + } dark:^(NSTextField *label) { + label.textColor = [NSColor ez_resultTextDarkColor]; + }]; + }]; + } + return _tipsContentLabel; +} + +- (EZOpenLinkButton *)moreBtn { + if (!_moreBtn) { + _moreBtn = [[EZOpenLinkButton alloc] init]; + [self addSubview:_moreBtn]; + NSImage *moreBtnImage = [NSImage ez_imageWithSymbolName:@"ellipsis.circle.fill"]; + _moreBtn.image = moreBtnImage; + _moreBtn.title = NSLocalizedString(@"tips_more", nil); + _moreBtn.imagePosition = NSImageLeft; + _moreBtn.edgeInsets = NSEdgeInsetsMake(0, 3, 0, 3); + [_moreBtn excuteLight:^(NSButton *button) { + button.image = [button.image imageWithTintColor:[NSColor ez_imageTintLightColor]]; + } dark:^(NSButton *button) { + button.image = [button.image imageWithTintColor:[NSColor ez_imageTintDarkColor]]; + }]; + _moreBtn.link = self.seeMoreURL; + } + return _moreBtn; +} + +- (EZOpenLinkButton *)solveBtn { + if (!_solveBtn) { + _solveBtn = [[EZOpenLinkButton alloc] init]; + [self addSubview:_solveBtn]; + NSImage *solveBtnImage = [NSImage ez_imageWithSymbolName:@"link.circle.fill"]; + _solveBtn.image = solveBtnImage; + _solveBtn.imagePosition = NSImageLeft; + _solveBtn.title = NSLocalizedString(@"tips_solve", nil); + _solveBtn.edgeInsets = NSEdgeInsetsMake(0, 3, 0, 3); + [_solveBtn excuteLight:^(NSButton *button) { + button.image = [button.image imageWithTintColor:[NSColor ez_imageTintLightColor]]; + } dark:^(NSButton *button) { + button.image = [button.image imageWithTintColor:[NSColor ez_imageTintDarkColor]]; + }]; + } + return _solveBtn; +} + +- (NSDictionary *)dataDict { + if (!_dataDict) { + _dataDict = @{ + @"questions" : @[ + NSLocalizedString(@"tips_text_empty", nil), + NSLocalizedString(@"tips_mouse_hover", nil), + NSLocalizedString(@"tips_beep", nil), + NSLocalizedString(@"tips_edit_button", nil), + NSLocalizedString(@"tips_might_selecting", nil), + NSLocalizedString(@"tips_word_selection_OCR", nil), + NSLocalizedString(@"tips_select_words", nil), + NSLocalizedString(@"tips_still_pop_up", nil), + ], + @"solveEn" : @[ + @"https://github.com/tisfeng/Easydict/wiki/FAQ#why-is-the-text-empty-when-i-select-words-in-some-applications", + @"https://github.com/tisfeng/Easydict/wiki/FAQ#why-cant-i-use-mouse-hover-to-select-words-in-some-applications", + @"https://github.com/tisfeng/Easydict/wiki/FAQ#why-is-there-a-beep-when-the-selected-word-is-empty-such-as-dragging-in-a-blank-area-in-some-applications", + @"https://github.com/tisfeng/Easydict/wiki/FAQ#why-does-the-edit-button-in-the-upper-right-corner-flicker-when-selecting-words-in-some-applications", + @"https://github.com/tisfeng/Easydict/wiki/FAQ#why-might-selecting-an-empty-word-interrupt-the-music-currently-playing", + @"https://github.com/tisfeng/Easydict/wiki/FAQ#why-do-word-selection-and-ocr-need-to-enable-system-related-permissions", + @"https://github.com/tisfeng/Easydict/wiki/FAQ#why-cant-i-select-words-on-some-web-pages-in-the-browser", + @"https://github.com/tisfeng/Easydict/wiki/FAQ#why-does-macos-still-pop-up-asking-for-permissions-even-though-i-have-given-easydict-the-accessibilityscreen-recording-permissions" + ], + @"solveZh" : @[ + @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9C%A8%E6%9F%90%E4%BA%9B%E5%BA%94%E7%94%A8%E4%B8%AD%E5%8F%96%E8%AF%8D%E6%96%87%E6%9C%AC%E4%B8%BA%E7%A9%BA", + @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9C%A8%E6%9F%90%E4%BA%9B%E5%BA%94%E7%94%A8%E4%B8%AD%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%E9%BC%A0%E6%A0%87%E5%88%92%E8%AF%8D", + @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9C%A8%E6%9F%90%E4%BA%9B%E5%BA%94%E7%94%A8%E5%8F%96%E8%AF%8D%E4%B8%BA%E7%A9%BA%E7%A9%BA%E7%99%BD%E5%A4%84%E6%8B%96%E5%8A%A8%E7%AD%89%E6%97%B6%E4%BC%9A%E5%87%BA%E7%8E%B0%E6%8F%90%E7%A4%BA%E9%9F%B3", + @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9C%A8%E6%9F%90%E4%BA%9B%E5%BA%94%E7%94%A8%E5%8F%96%E8%AF%8D%E6%97%B6%E5%8F%B3%E4%B8%8A%E8%A7%92%E7%BC%96%E8%BE%91%E6%8C%89%E9%92%AE%E4%BC%9A%E5%87%BA%E7%8E%B0%E9%97%AA%E7%83%81", + @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E4%B8%BA%E4%BB%80%E4%B9%88%E5%8F%96%E8%AF%8D%E4%B8%BA%E7%A9%BA%E6%97%B6%E5%8F%AF%E8%83%BD%E6%89%93%E6%96%AD%E5%BD%93%E5%89%8D%E6%92%AD%E6%94%BE%E7%9A%84%E9%9F%B3%E4%B9%90", + @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E4%B8%BA%E4%BB%80%E4%B9%88%E5%8F%96%E8%AF%8D%E5%92%8C-ocr-%E9%9C%80%E8%A6%81%E5%BC%80%E5%90%AF%E7%B3%BB%E7%BB%9F%E7%9B%B8%E5%85%B3%E6%9D%83%E9%99%90", + @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E4%B8%BA%E4%BB%80%E4%B9%88%E6%B5%8F%E8%A7%88%E5%99%A8%E4%B8%AD%E6%9F%90%E4%BA%9B%E7%BD%91%E9%A1%B5%E6%97%A0%E6%B3%95%E5%8F%96%E8%AF%8D", + @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E5%B7%B2%E7%BB%8F%E7%BB%99-easydict-%E8%BE%85%E5%8A%A9%E5%8A%9F%E8%83%BD%E5%BD%95%E5%B1%8F%E6%9D%83%E9%99%90-macos-%E4%BB%8D%E7%84%B6%E5%BC%B9%E7%AA%97%E8%A6%81%E6%B1%82%E7%BB%99%E4%BA%88%E6%9D%83%E9%99%90" + ], + }; + } + return _dataDict; +} + +- (NSString *)seeMoreURL { + if (!_seeMoreURL) { + if ([EZLanguageManager.shared isSystemChineseFirstLanguage]) { + _seeMoreURL = @"https://github.com/tisfeng/Easydict/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98"; + } else { + _seeMoreURL = @"https://github.com/tisfeng/Easydict/wiki/FAQ"; + } + } + return _seeMoreURL; +} +@end diff --git a/Easydict/Feature/ViewController/View/CustomButton/EZButton/EZButton.h b/Easydict/Feature/ViewController/View/CustomButton/EZButton/EZButton.h index 8426194ab..333c13991 100644 --- a/Easydict/Feature/ViewController/View/CustomButton/EZButton/EZButton.h +++ b/Easydict/Feature/ViewController/View/CustomButton/EZButton/EZButton.h @@ -65,6 +65,8 @@ typedef NS_ENUM(NSUInteger, EZButtonState) { @property (nonatomic, copy) NSAttributedString *attrTitle; +@property (nonatomic, assign) NSEdgeInsets edgeInsets; // setting button padding + @property (nonatomic, copy, nullable) void (^clickBlock)(EZButton *button); @property (nonatomic, copy, nullable) void (^mouseEnterBlock)(EZButton *button); diff --git a/Easydict/Feature/ViewController/View/CustomButton/EZButton/EZButton.m b/Easydict/Feature/ViewController/View/CustomButton/EZButton/EZButton.m index 5226f8e39..acd2490bc 100644 --- a/Easydict/Feature/ViewController/View/CustomButton/EZButton/EZButton.m +++ b/Easydict/Feature/ViewController/View/CustomButton/EZButton/EZButton.m @@ -39,6 +39,12 @@ - (void)viewWillMoveToSuperview:(NSView *)newSuperview { [self updateButtonApperaceWithState:self.buttonState]; } +- (void)drawRect:(NSRect)dirtyRect { + NSRect originRect = self.bounds; + self.bounds = NSInsetRect(originRect, self.edgeInsets.left + self.edgeInsets.right, self.edgeInsets.top + self.edgeInsets.bottom); + [super drawRect:dirtyRect]; + self.bounds = originRect; +} #pragma mark - Mouse Actions diff --git a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h index c6a0136a6..2ab27da7f 100644 --- a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h +++ b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h @@ -62,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)disableReplaceTextButton; +- (void)updateActionType:(EZActionType)actionType; - (void)receiveTitlebarAction:(EZTitlebarAction)action; @end diff --git a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index 19b5d85f3..ff6bcbdad 100644 --- a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -11,6 +11,7 @@ #import "EZQueryView.h" #import "EZResultView.h" #import "EZSelectLanguageCell.h" +#import "EZTableTipsCell.h" #import #import "EZCoordinateUtils.h" #import "EZWindowManager.h" @@ -32,6 +33,7 @@ static NSString *const EZQueryViewId = @"EZQueryViewId"; static NSString *const EZSelectLanguageCellId = @"EZSelectLanguageCellId"; +static NSString *const EZTableTipsCellId = @"EZTableTipsCellId"; static NSString *const EZResultViewId = @"EZResultViewId"; static NSString *const EZColumnId = @"EZColumnId"; @@ -55,6 +57,7 @@ @interface EZBaseQueryViewController () ("disableTipsViewKey", default: false) } extension Defaults.Keys { diff --git a/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift b/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift index c53648b10..b28381b93 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/AdvancedTab.swift @@ -26,7 +26,9 @@ struct AdvancedTab: View { Toggle(isOn: $enableBetaNewApp) { Text("enable_beta_new_app") } - + Toggle(isOn: $disableTipsView) { + Text("disable_tips_view") + } } header: { Text("setting.general.advance.header") } @@ -39,6 +41,7 @@ struct AdvancedTab: View { @Default(.defaultTTSServiceType) private var defaultTTSServiceType @Default(.enableBetaFeature) private var enableBetaFeature @Default(.enableBetaNewApp) private var enableBetaNewApp + @Default(.disableTipsView) private var disableTipsView } @available(macOS 13, *) From 4169f64b0b62314b02db7896f6c4795b7820960d Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Sun, 7 Apr 2024 11:07:24 +0800 Subject: [PATCH 02/24] fix: https://github.com/tisfeng/Easydict/issues/452 blank for tips view --- .../EZBaseQueryViewController.m | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index ff6bcbdad..dffc4055a 100644 --- a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -78,7 +78,7 @@ @interface EZBaseQueryViewController () Date: Sun, 7 Apr 2024 14:17:17 +0800 Subject: [PATCH 03/24] feat: add type of tips cell --- .../ViewController/Cell/EZTableTipsCell.h | 21 ++++++++++++ .../ViewController/Cell/EZTableTipsCell.m | 33 +++++++++++++------ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.h b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.h index c217083d2..4a16ada12 100644 --- a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.h +++ b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.h @@ -10,10 +10,31 @@ NS_ASSUME_NONNULL_BEGIN +typedef NS_ENUM(NSInteger, EZTipsCellType) { + EZTipsCellTypeNone = -1, + EZTipsCellTypeTextEmpty = 0, + EZTipsCellTypeMouseHover, + EZTipsCellTypeBeep, + EZTipsCellTypeEditButton, + EZTipsCellTypeMightSelecting, + EZTipsCellTypeWordSelectionOCR, + EZTipsCellTypeSelectWords, + EZTipsCellTypeStillPopup, +}; + @interface EZTableTipsCell : NSTableRowView - (CGFloat)cellHeight; + +- (instancetype)initWithFrame:(CGRect)frame type:(EZTipsCellType)type; + +/// update tips cell content with type +/// - Parameters: +/// - content: string value for content +/// - type: cell type default value is none +- (void)updateTipsContent:(NSString *)content type:(EZTipsCellType)type; + @end NS_ASSUME_NONNULL_END diff --git a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m index 1d7563be5..634eff33d 100644 --- a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m +++ b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m @@ -21,19 +21,26 @@ @interface EZTableTipsCell () @property (nonatomic, strong) NSDictionary *dataDict; @property (nonatomic, strong) NSString *questionSolveURL; @property (nonatomic, strong) NSString *seeMoreURL; +@property (nonatomic, assign) EZTipsCellType tipsType; @end @implementation EZTableTipsCell -- (instancetype)initWithFrame:(NSRect)frame { +- (instancetype)initWithFrame:(CGRect)frame type:(EZTipsCellType)type { self = [super initWithFrame:frame]; if (self) { + self.tipsType = type; [self setupUI]; [self updateQuestionContent]; } return self; } +- (void)updateTipsContent:(NSString *)content type:(EZTipsCellType)type { + self.tipsContentLabel.stringValue = content; + self.tipsType = type; +} + - (void)setupUI { // mas key self.contentView.mas_key = @"topBarView"; @@ -84,17 +91,23 @@ - (void)updateConstraints { } - (void)updateQuestionContent { - NSArray *questions = self.dataDict[@"questions"]; - int index = arc4random() % questions.count; - self.tipsContentLabel.stringValue = questions[index]; - NSArray *solves; - if ([EZLanguageManager.shared isSystemChineseFirstLanguage]) { - solves = self.dataDict[@"solveZh"]; + // random question and slove + if (self.tipsType == EZTipsCellTypeNone) { + NSArray *questions = self.dataDict[@"questions"]; + int index = arc4random() % questions.count; + self.tipsContentLabel.stringValue = questions[index]; + NSArray *solves; + if ([EZLanguageManager.shared isSystemChineseFirstLanguage]) { + solves = self.dataDict[@"solveZh"]; + } else { + solves = self.dataDict[@"solveEn"]; + } + self.questionSolveURL = solves[index]; + self.solveBtn.link = self.questionSolveURL; } else { - solves = self.dataDict[@"solveEn"]; + + } - self.questionSolveURL = solves[index]; - self.solveBtn.link = self.questionSolveURL; } - (CGFloat)cellHeight { From e1fa270972b3c43c22b898c7b0cad857ade63f2e Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Mon, 8 Apr 2024 15:04:05 +0800 Subject: [PATCH 04/24] feat: support tips cell update cell type --- .../ViewController/Cell/EZTableTipsCell.h | 5 +++ .../ViewController/Cell/EZTableTipsCell.m | 39 ++++++++++++------- .../EZBaseQueryViewController.m | 8 ++-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.h b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.h index 4a16ada12..8782c3ea0 100644 --- a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.h +++ b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.h @@ -35,6 +35,11 @@ typedef NS_ENUM(NSInteger, EZTipsCellType) { /// - type: cell type default value is none - (void)updateTipsContent:(NSString *)content type:(EZTipsCellType)type; + +/// update tips cell of type +/// - Parameter type: cell type default value is none +- (void)updateTipsCellType:(EZTipsCellType)type; + @end NS_ASSUME_NONNULL_END diff --git a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m index 634eff33d..d92085e73 100644 --- a/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m +++ b/Easydict/Feature/ViewController/Cell/EZTableTipsCell.m @@ -10,6 +10,7 @@ #import "EZOpenLinkButton.h" #import "NSImage+EZSymbolmage.h" #import "EZLanguageManager.h" +#import "NSString+EZUtils.h" @interface EZTableTipsCell () @property (nonatomic, strong) NSView *contentView; @@ -36,9 +37,16 @@ - (instancetype)initWithFrame:(CGRect)frame type:(EZTipsCellType)type { return self; } +- (void)updateTipsCellType:(EZTipsCellType)type { + [self updateTipsContent:@"" type:type]; +} + - (void)updateTipsContent:(NSString *)content type:(EZTipsCellType)type { - self.tipsContentLabel.stringValue = content; + if (!EZ_isEmptyString(content)) { + self.tipsContentLabel.stringValue = content; + } self.tipsType = type; + [self updateQuestionContent]; } - (void)setupUI { @@ -91,23 +99,24 @@ - (void)updateConstraints { } - (void)updateQuestionContent { - // random question and slove + NSArray *questions = self.dataDict[@"questions"]; + NSInteger index = 0; if (self.tipsType == EZTipsCellTypeNone) { - NSArray *questions = self.dataDict[@"questions"]; - int index = arc4random() % questions.count; - self.tipsContentLabel.stringValue = questions[index]; - NSArray *solves; - if ([EZLanguageManager.shared isSystemChineseFirstLanguage]) { - solves = self.dataDict[@"solveZh"]; - } else { - solves = self.dataDict[@"solveEn"]; - } - self.questionSolveURL = solves[index]; - self.solveBtn.link = self.questionSolveURL; + // random question and slove + index = arc4random() % questions.count; + } else { + // show special question + index = self.tipsType; + } + self.tipsContentLabel.stringValue = questions[index]; + NSArray *solves; + if ([EZLanguageManager.shared isSystemChineseFirstLanguage]) { + solves = self.dataDict[@"solveZh"]; } else { - - + solves = self.dataDict[@"solveEn"]; } + self.questionSolveURL = solves[index]; + self.solveBtn.link = self.questionSolveURL; } - (CGFloat)cellHeight { diff --git a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index dffc4055a..db593fdd1 100644 --- a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -532,9 +532,7 @@ - (void)startOCRImage:(NSImage *)image actionType:(EZActionType)actionType { [self updateQueryTextAndParagraphStyle:inputText actionType:actionType]; if (error) { - NSString *errorMsg = [error localizedDescription]; - self.queryView.alertText = errorMsg; - + [self.tipsCell updateTipsCellType:EZTipsCellTypeWordSelectionOCR]; self.showTipsView = [self isShowTipsView]; [self.tableView reloadData]; [self updateWindowViewHeight]; @@ -631,9 +629,11 @@ - (void)toggleTranslationLanguages { [self.selectLanguageCell toggleTranslationLanguages]; } +// will close Window - (void)stopPlayingQueryText { [self togglePlayQueryText:NO]; [self stopAllResultAudio]; + [self.tipsCell updateTipsCellType:EZTipsCellTypeNone]; } - (void)togglePlayQueryText { @@ -874,7 +874,7 @@ - (nullable NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(null if (row == 2 && self.showTipsView && !self.hasShowTips) { EZTableTipsCell *tipsCell = [self.tableView makeViewWithIdentifier:EZTableTipsCellId owner:self]; if (!tipsCell) { - tipsCell = [[EZTableTipsCell alloc] initWithFrame:[self tableViewContentBounds]]; + tipsCell = [[EZTableTipsCell alloc] initWithFrame:[self tableViewContentBounds] type:EZTipsCellTypeNone]; tipsCell.identifier = EZTableTipsCellId; } self.tipsCell = tipsCell; From 33ac9af64adda776d00aa5ed44427c6bdc809d0d Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Mon, 8 Apr 2024 15:20:36 +0800 Subject: [PATCH 05/24] fix: when selection translation the text is empty set special tips cell type --- .../Window/BaseQueryWindow/EZBaseQueryViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index db593fdd1..e56aa88d0 100644 --- a/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/Feature/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -532,7 +532,7 @@ - (void)startOCRImage:(NSImage *)image actionType:(EZActionType)actionType { [self updateQueryTextAndParagraphStyle:inputText actionType:actionType]; if (error) { - [self.tipsCell updateTipsCellType:EZTipsCellTypeWordSelectionOCR]; +// [self.tipsCell updateTipsCellType:EZTipsCellTypeWordSelectionOCR]; self.showTipsView = [self isShowTipsView]; [self.tableView reloadData]; [self updateWindowViewHeight]; @@ -633,7 +633,7 @@ - (void)toggleTranslationLanguages { - (void)stopPlayingQueryText { [self togglePlayQueryText:NO]; [self stopAllResultAudio]; - [self.tipsCell updateTipsCellType:EZTipsCellTypeNone]; + [self.tipsCell updateTipsCellType:EZTipsCellTypeTextEmpty]; } - (void)togglePlayQueryText { @@ -874,7 +874,7 @@ - (nullable NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(null if (row == 2 && self.showTipsView && !self.hasShowTips) { EZTableTipsCell *tipsCell = [self.tableView makeViewWithIdentifier:EZTableTipsCellId owner:self]; if (!tipsCell) { - tipsCell = [[EZTableTipsCell alloc] initWithFrame:[self tableViewContentBounds] type:EZTipsCellTypeNone]; + tipsCell = [[EZTableTipsCell alloc] initWithFrame:[self tableViewContentBounds] type:EZTipsCellTypeTextEmpty]; tipsCell.identifier = EZTableTipsCellId; } self.tipsCell = tipsCell; From 3e625a49a870c3a1869e5477aae83c4c0b04de0a Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Mon, 8 Apr 2024 15:46:27 +0800 Subject: [PATCH 06/24] fix: update show tips status --- .../Window/BaseQueryWindow/EZBaseQueryViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index e80b100d1..9eeae4041 100644 --- a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -127,10 +127,10 @@ - (void)viewWillAppear { } - (void)recoverStatus { + self.hasShowTips = NO; self.showTipsView = [self isShowTipsView]; [self.tableView reloadData]; [self updateWindowViewHeight]; - self.hasShowTips = NO; } - (void)setupData { From e9d5f3eeeb823b0978109ee55fc2e81bc5b12b2d Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Mon, 8 Apr 2024 16:58:22 +0800 Subject: [PATCH 07/24] fix: resolve merge dev --- .../Window/BaseQueryWindow/EZBaseQueryViewController.h | 2 ++ .../ViewController/Window/WindowManager/EZWindowManager.m | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h index 42cd85c3a..071e261fe 100644 --- a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h +++ b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h @@ -64,6 +64,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)receiveTitlebarAction:(EZTitlebarQuickAction)action; +- (void)updateActionType:(EZActionType)actionType; + @end NS_ASSUME_NONNULL_END diff --git a/Easydict/objc/ViewController/Window/WindowManager/EZWindowManager.m b/Easydict/objc/ViewController/Window/WindowManager/EZWindowManager.m index 5197fd52c..1f39e2b58 100644 --- a/Easydict/objc/ViewController/Window/WindowManager/EZWindowManager.m +++ b/Easydict/objc/ViewController/Window/WindowManager/EZWindowManager.m @@ -320,11 +320,12 @@ - (void)showFloatingWindowType:(EZWindowType)windowType } EZBaseQueryWindow *window = [self windowWithType:windowType]; - + EZBaseQueryViewController *queryViewController = window.queryViewController; // If text is nil, means we don't need to query anything, just show the window. if (!queryText) { // !!!: location is top-left point, so we need to change it to bottom-left point. CGPoint newPoint = CGPointMake(point.x, point.y - window.height); + [queryViewController updateActionType:self.actionType]; [self showFloatingWindow:window atPoint:newPoint]; if (completionHandler) { @@ -337,8 +338,6 @@ - (void)showFloatingWindowType:(EZWindowType)windowType // Log selected text when querying. [self logSelectedTextEvent]; - EZBaseQueryViewController *queryViewController = window.queryViewController; - void (^updateQueryTextAndStartQueryBlock)(BOOL) = ^(BOOL needFocus) { // Update input text and detect. [queryViewController updateQueryTextAndParagraphStyle:queryText actionType:self.actionType]; From 4c3be7e3600c3eca00478546f72d4acd5db26713 Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Mon, 8 Apr 2024 21:49:32 +0800 Subject: [PATCH 08/24] fix: update action type --- .../objc/ViewController/Window/WindowManager/EZWindowManager.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Easydict/objc/ViewController/Window/WindowManager/EZWindowManager.m b/Easydict/objc/ViewController/Window/WindowManager/EZWindowManager.m index 1f39e2b58..d7fca6402 100644 --- a/Easydict/objc/ViewController/Window/WindowManager/EZWindowManager.m +++ b/Easydict/objc/ViewController/Window/WindowManager/EZWindowManager.m @@ -367,6 +367,7 @@ - (void)showFloatingWindowType:(EZWindowType)windowType [queryViewController resetTableView:^{ // !!!: window height has changed, so we need to update location again. CGPoint newPoint = CGPointMake(point.x, point.y - window.height); + [queryViewController updateActionType:self.actionType]; [self showFloatingWindow:window atPoint:newPoint]; updateQueryTextAndStartQueryBlock(NO); }]; From 1b98c974f6a3c0afc8fa7b5e0d78cb88df61b0ef Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Mon, 8 Apr 2024 22:42:58 +0800 Subject: [PATCH 09/24] pref: stash ocr error tips --- .../Window/BaseQueryWindow/EZBaseQueryViewController.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index 9eeae4041..07dd51fd5 100644 --- a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -531,8 +531,9 @@ - (void)startOCRImage:(NSImage *)image actionType:(EZActionType)actionType { [self updateQueryTextAndParagraphStyle:inputText actionType:actionType]; if (error) { + // TODO: Sharker fix OCR Error in tips // [self.tipsCell updateTipsCellType:EZTipsCellTypeWordSelectionOCR]; - self.showTipsView = [self isShowTipsView]; + self.showTipsView = NO; [self.tableView reloadData]; [self updateWindowViewHeight]; return; From 306b3ade4381ceb7d3a2c471a3ebcb4bc1824f79 Mon Sep 17 00:00:00 2001 From: Sharker <1548742234@qq.com> Date: Tue, 23 Apr 2024 10:31:53 +0800 Subject: [PATCH 10/24] fix: control show tips code --- .../EZBaseQueryViewController.h | 5 ++ .../EZBaseQueryViewController.m | 58 +++++++------------ .../Window/WindowManager/EZWindowManager.m | 8 +++ 3 files changed, 33 insertions(+), 38 deletions(-) diff --git a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h index 071e261fe..e1c95ea14 100644 --- a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h +++ b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.h @@ -11,6 +11,7 @@ #import "EZQueryModel.h" #import "EZQueryResult.h" #import "EZTitlebar.h" +#import "EZTableTipsCell.h" NS_ASSUME_NONNULL_BEGIN @@ -66,6 +67,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)updateActionType:(EZActionType)actionType; +/// show tips with type +/// - Parameters: +/// - show: whether to show +- (void)showTipsView:(BOOL)show; @end NS_ASSUME_NONNULL_END diff --git a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m index b88fe4b64..b5821c847 100644 --- a/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m +++ b/Easydict/objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m @@ -11,7 +11,6 @@ #import "EZQueryView.h" #import "EZResultView.h" #import "EZSelectLanguageCell.h" -#import "EZTableTipsCell.h" #import #import "EZCoordinateUtils.h" #import "EZWindowManager.h" @@ -79,7 +78,6 @@ @interface EZBaseQueryViewController ()