Skip to content

Commit

Permalink
Merge branch 'dev' into swift-openai
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Apr 2, 2024
2 parents 0c4a60c + 3d5ea5b commit a9f464a
Show file tree
Hide file tree
Showing 10 changed files with 346 additions and 234 deletions.
78 changes: 55 additions & 23 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -501,34 +501,34 @@
}
}
},
"automatic_word_segmentation" : {
"automatically_remove_code_comment_symbols" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Automatically splitting words: key_value —> key value"
"value" : "Automatically remove code comment symbols「/*#」"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "单词自动分词 key_value —> key value"
"value" : "自动去除代码注释符号「/*#」"
}
}
}
},
"automatically_remove_code_comment_symbols" : {
"automatically_split_words" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Automatically remove code comment symbols「/*#」"
"value" : "Automatically split words: key_value —> key value"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "自动去除代码注释符号「/*#」"
"value" : "单词自动分词 key_value —> key value"
}
}
}
Expand Down Expand Up @@ -2432,6 +2432,22 @@
}
}
},
"quick_action" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Quick action"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "快捷动作"
}
}
}
},
"quick_link" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -2497,6 +2513,22 @@
}
}
},
"replace_newline_with_space" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Replace newline with space"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "将「换行符」替换为「空格」"
}
}
}
},
"replace_text" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -2685,7 +2717,7 @@
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"state" : "translated",
"value" : "模型名字,多个模型使用逗号(,)分隔"
}
}
Expand Down Expand Up @@ -4204,6 +4236,22 @@
}
}
},
"split_words" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Split words"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "单词分词"
}
}
}
},
"stop_play_audio" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -4403,22 +4451,6 @@
}
}
},
"word_segmentation" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Splitting words"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "单词分词"
}
}
}
},
"Youdao" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extension Defaults.Keys {
static let showGoogleQuickLink = Key<Bool>("EZConfiguration_kShowGoogleLinkKey", default: true)
static let showEudicQuickLink = Key<Bool>("EZConfiguration_kShowEudicLinkKey", default: true)
static let showAppleDictionaryQuickLink = Key<Bool>("EZConfiguration_kShowAppleDictionaryLinkKey", default: true)
static let showSettingQuickLink = Key<Bool>("EZConfiguration_kShowSettingQuickLink", default: true)
static let showQuickActionButton = Key<Bool>("EZConfiguration_kShowSettingQuickLink", default: true)
static let hideMenuBarIcon = Key<Bool>("EZConfiguration_kHideMenuBarIconKey", default: false)
static let fixedWindowPosition = Key<EZShowWindowPosition>(
"EZConfiguration_kShowFixedWindowPositionKey",
Expand Down
6 changes: 3 additions & 3 deletions Easydict/Swift/Feature/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Configuration: NSObject {

@DefaultsWrapper(.enableBetaFeature) private(set) var beta: Bool

@DefaultsWrapper(.showSettingQuickLink) var showSettingQuickLink: Bool
@DefaultsWrapper(.showQuickActionButton) var showQuickActionButton: Bool

var cancellables: [AnyCancellable] = []

Expand Down Expand Up @@ -323,7 +323,7 @@ class Configuration: NSObject {
)

cancellables.append(
Defaults.publisher(.showSettingQuickLink, options: [])
Defaults.publisher(.showQuickActionButton, options: [])
.removeDuplicates()
.sink { [weak self] _ in
self?.didSetShowSettingQuickLink()
Expand Down Expand Up @@ -537,7 +537,7 @@ extension Configuration {
func didSetShowSettingQuickLink() {
postUpdateQuickLinkButtonNotification()

logSettings(["showSettingQuickLink": showSettingQuickLink])
logSettings(["showSettingQuickLink": showQuickActionButton])
}

fileprivate func didSetHideMenuBarIcon() {
Expand Down
6 changes: 3 additions & 3 deletions Easydict/Swift/View/SettingView/Tabs/GeneralTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct GeneralTab: View {
Toggle("keep_prev_result_when_selected_text_is_empty", isOn: $keepPrevResultWhenEmpty)
Toggle("select_query_text_when_window_activate", isOn: $selectQueryTextWhenWindowActivate)
Toggle("automatically_remove_code_comment_symbols", isOn: $automaticallyRemoveCodeCommentSymbols)
Toggle("automatic_word_segmentation", isOn: $automaticWordSegmentation)
Toggle("automatically_split_words", isOn: $automaticWordSegmentation)
} header: {
Text("setting.general.input.header")
}
Expand All @@ -144,7 +144,7 @@ struct GeneralTab: View {
Toggle("show_google_quick_link", isOn: $showGoogleQuickLink)
Toggle("show_eudic_quick_link", isOn: $showEudicQuickLink)
Toggle("show_apple_dictionary_quick_link", isOn: $showAppleDictionaryQuickLink)
Toggle("show_setting_quick_link", isOn: $showSettingQuickLink)
Toggle("show_setting_quick_link", isOn: $showQuickActionButton)
} header: {
Text("setting.general.quick_link.header")
}
Expand Down Expand Up @@ -278,7 +278,7 @@ struct GeneralTab: View {
@Default(.showGoogleQuickLink) private var showGoogleQuickLink
@Default(.showEudicQuickLink) private var showEudicQuickLink
@Default(.showAppleDictionaryQuickLink) private var showAppleDictionaryQuickLink
@Default(.showSettingQuickLink) private var showSettingQuickLink
@Default(.showQuickActionButton) private var showQuickActionButton

@Default(.hideMainWindow) private var hideMainWindow
@Default(.launchAtStartup) private var launchAtStartup
Expand Down
6 changes: 3 additions & 3 deletions Easydict/objc/PerferenceWindow/EZSettingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ - (void)setupUI {
self.selectQueryTextWhenWindowActivateButton = [NSButton checkboxWithTitle:selectQueryTextWhenWindowActivateTitle target:self action:@selector(selectQueryTextWhenWindowActivateButtonClicked:)];
[self.contentView addSubview:self.selectQueryTextWhenWindowActivateButton];

self.automaticWordSegmentationButton = [NSButton checkboxWithTitle:NSLocalizedString(@"automatic_word_segmentation", nil) target:self action:@selector(automaticWordSegmentationButtonClicked:)];
self.automaticWordSegmentationButton = [NSButton checkboxWithTitle:NSLocalizedString(@"automatically_split_words", nil) target:self action:@selector(automaticWordSegmentationButtonClicked:)];
[self.contentView addSubview:self.automaticWordSegmentationButton];

self.automaticallyRemoveCodeCommentSymbolsButton = [NSButton checkboxWithTitle:NSLocalizedString(@"automatically_remove_code_comment_symbols", nil) target:self action:@selector(automaticallyRemoveCodeCommentSymbolsButtonClicked:)];
Expand Down Expand Up @@ -583,7 +583,7 @@ - (void)setupUI {
self.showGoogleQuickLinkButton.mm_isOn = self.config.showGoogleQuickLink;
self.showEudicQuickLinkButton.mm_isOn = self.config.showEudicQuickLink;
self.showAppleDictionaryQuickLinkButton.mm_isOn = self.config.showAppleDictionaryQuickLink;
self.showSettingQuickLinkButton.mm_isOn = self.config.showSettingQuickLink;
self.showSettingQuickLinkButton.mm_isOn = self.config.showQuickActionButton;
self.hideMenuBarIconButton.mm_isOn = self.config.hideMenuBarIcon;
if (@available(macOS 13.0, *)) {
self.enableBetaNewAppButton.mm_isOn = self.config.enableBetaNewApp;
Expand Down Expand Up @@ -1058,7 +1058,7 @@ - (void)showAppleDictionaryQuickLinkButtonClicked:(NSButton *)sender {
}

- (void)showSettingQuickLinkButtonClicked:(NSButton *)sender {
self.config.showSettingQuickLink = sender.mm_isOn;
self.config.showQuickActionButton = sender.mm_isOn;
}

- (void)hideMenuBarIconButtonClicked:(NSButton *)sender {
Expand Down
16 changes: 7 additions & 9 deletions Easydict/objc/ViewController/View/Titlebar/EZTitlebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
//

#import <Cocoa/Cocoa.h>
#import "EZHoverButton.h"
#import "EZOpenLinkButton.h"

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, EZTitlebarAction) {
EZTitlebarActionRemoveCommentBlockSymbols,
EZTitlebarActionWordsSegmentation,
typedef NS_ENUM(NSUInteger, EZTitlebarQuickAction) {
EZTitlebarQuickActionRemoveCommentBlockSymbols,
EZTitlebarQuickActionWordsSegmentation,
EZTitlebarQuickActionReplaceNewlineWithSpace,
};

typedef void(^EZTitlebarActionBlock)(EZTitlebarAction);
typedef void(^EZTitlebarQuickActionBlock)(EZTitlebarQuickAction);

@interface EZTitlebar : NSView

Expand All @@ -29,11 +29,9 @@ typedef void(^EZTitlebarActionBlock)(EZTitlebarAction);
@property (nonatomic, strong) EZOpenLinkButton *googleButton;
@property (nonatomic, strong) EZOpenLinkButton *appleDictionaryButton;

@property (nonatomic, strong) EZOpenLinkButton *favoriteButton;
@property (nonatomic, strong) EZOpenLinkButton *quickActionButton;

@property (nonatomic, strong) EZOpenLinkButton *settingButton;

@property (nonatomic, copy) EZTitlebarActionBlock menuActionBlock;
@property (nonatomic, copy) EZTitlebarQuickActionBlock menuActionBlock;

@end

Expand Down
Loading

0 comments on commit a9f464a

Please sign in to comment.