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 action to replace newline with space #483

Merged
merged 8 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions Easydict/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/Feature/PerferenceWindow/EZSettingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,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 @@ -584,7 +584,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 @@ -1059,7 +1059,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/Feature/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