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

Add settings to shortcuts #416

Merged
merged 34 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d36ff43
add button and menu
NeverAgain11 Feb 20, 2024
ae816e4
add action to the menu
NeverAgain11 Feb 21, 2024
ccd1dc3
replace setting icon
NeverAgain11 Feb 21, 2024
e3c37dd
Merge branch 'dev' into add_setting_icon_to_shortcuts
tisfeng Feb 21, 2024
c930758
Update Easydict/App/Localizable.xcstrings
NeverAgain11 Feb 22, 2024
2ec768a
Update Easydict/App/Localizable.xcstrings
NeverAgain11 Feb 22, 2024
deb8785
Update Easydict/App/Localizable.xcstrings
NeverAgain11 Feb 22, 2024
57ee6b0
Fix the setting button frame and set the color for light and dark mode.
NeverAgain11 Feb 22, 2024
9206a42
fix: open settings in appKit
phlpsong Feb 22, 2024
faa70aa
fix: conflicts with NSAppleEventManager issue
phlpsong Feb 23, 2024
f3fe566
fix: check os when open settings
phlpsong Feb 23, 2024
bcf739c
fix: optimize logic
phlpsong Feb 23, 2024
7bc4bf4
Merge pull request #1 from phlpsong/open_settings_appkit
NeverAgain11 Feb 23, 2024
51ac703
allows hiding the setting icon.
NeverAgain11 Feb 23, 2024
2ceeefd
Merge branch 'dev' into add_setting_icon_to_shortcuts
tisfeng Feb 23, 2024
fb8be8a
perf: improve quick action menu item title
tisfeng Feb 23, 2024
9946f2a
Merge branch 'dev' into add_setting_icon_to_shortcuts
tisfeng Feb 25, 2024
f1e65bd
Merge branch 'dev' into add_setting_icon_to_shortcuts
phlpsong Feb 25, 2024
dac93f0
Merge branch 'dev' into add_setting_icon_to_shortcuts
NeverAgain11 Feb 25, 2024
9abef85
Merge branch 'dev' into add_setting_icon_to_shortcuts
tisfeng Feb 26, 2024
b3eb427
perf: update Localizable.xcstrings
tisfeng Feb 27, 2024
e5d9dc4
perf(UI): change quick setting button tint color to light blue
tisfeng Feb 27, 2024
ab77224
Merge branch 'dev' into add_setting_icon_to_shortcuts
tisfeng Feb 27, 2024
c9d60ce
Merge remote-tracking branch 'tisfeng/dev' into add_setting_icon_to_s…
NeverAgain11 Mar 2, 2024
196b74b
Revert "perf(UI): change quick setting button tint color to light blue"
NeverAgain11 Mar 2, 2024
e844216
Change the actions in the quick settings.
NeverAgain11 Mar 5, 2024
738c278
add setting options
NeverAgain11 Mar 5, 2024
c95d8c9
Merge remote-tracking branch 'tisfeng/dev' into add_setting_icon_to_s…
NeverAgain11 Mar 5, 2024
941e263
Merge branch 'dev' into add_setting_icon_to_shortcuts
tisfeng Mar 5, 2024
3ff7fed
perf: improve handling title bar action
tisfeng Mar 6, 2024
f8e8116
perf: move handleInputText to NSString category
tisfeng Mar 6, 2024
f261da3
update Localizable.xcstrings
NeverAgain11 Mar 7, 2024
9c5bf73
perf: update Localizable.xcstrings
tisfeng Mar 7, 2024
b4cf1f1
Merge branch 'dev' into add_setting_icon_to_shortcuts
tisfeng Mar 7, 2024
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
1 change: 1 addition & 0 deletions Easydict/App/EZConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ static NSInteger const EZMaxFiveWordSynonymCount = 5;

static CGFloat const EZGetClipboardTextDelayTime = 0.1;

static NSString *const EZOpenSettingsNotification = @"EZOpenSettingsNotification";

#endif /* EZConst_h */
64 changes: 64 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,38 @@
}
}
},
"automatic_word_segmentation" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Word auto-splitting: key_value —> key value"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "单词自动分词 key_value —> key value"
}
}
}
},
"automatically_remove_code_comment_symbols" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Automatically remove code comment symbols「/*#」"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "自动去除代码注释符号「/*#」"
}
}
}
},
"avoid_conflict_with_PopClip_display" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -1366,6 +1398,22 @@
}
}
},
"go_to_settings" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Go to Settings"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "前往设置"
}
}
}
},
"google_translate" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -3929,6 +3977,22 @@
}
}
},
"show_setting_quick_link" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Show Setting quick link icon"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "显示快捷设置图标"
}
}
}
},
"silent_screenshot_ocr" : {
"localizations" : {
"en" : {
Expand Down
23 changes: 23 additions & 0 deletions Easydict/Feature/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ let kHideMenuBarIconKey = "EZConfiguration_kHideMenuBarIconKey"
@DefaultsWrapper(.showAppleDictionaryQuickLink)
var showAppleDictionaryQuickLink: Bool

@DefaultsWrapper(.showSettingQuickLink)
var showSettingQuickLink: Bool

@DefaultsWrapper(.hideMenuBarIcon)
var hideMenuBarIcon: Bool

Expand Down Expand Up @@ -147,6 +150,12 @@ let kHideMenuBarIconKey = "EZConfiguration_kHideMenuBarIconKey"
@DefaultsWrapper(.selectQueryTextWhenWindowActivate)
var selectQueryTextWhenWindowActivate: Bool

@DefaultsWrapper(.automaticWordSegmentation)
var automaticWordSegmentation: Bool

@DefaultsWrapper(.automaticallyRemoveCodeCommentSymbols)
var automaticallyRemoveCodeCommentSymbols: Bool

var disabledAutoSelect: Bool = false

var isRecordingSelectTextShortcutKey: Bool = false
Expand Down Expand Up @@ -331,6 +340,14 @@ let kHideMenuBarIconKey = "EZConfiguration_kHideMenuBarIconKey"
}
)

cancellables.append(
Defaults.publisher(.showSettingQuickLink, options: [])
.removeDuplicates()
.sink { [weak self] _ in
self?.didSetShowSettingQuickLink()
}
)

cancellables.append(
Defaults.publisher(.hideMenuBarIcon)
.removeDuplicates()
Expand Down Expand Up @@ -541,6 +558,12 @@ private extension Configuration {
logSettings(["show_apple_dictionary_link": showAppleDictionaryQuickLink])
}

func didSetShowSettingQuickLink() {
postUpdateQuickLinkButtonNotification()

logSettings(["showSettingQuickLink": showSettingQuickLink])
}

func didSetHideMenuBarIcon() {
if !Configuration.shared.enableBetaNewApp {
hideMenuBarIcon(hidden: hideMenuBarIcon)
Expand Down
19 changes: 16 additions & 3 deletions Easydict/Feature/PerferenceWindow/EZSettingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ @interface EZSettingViewController () <NSComboBoxDelegate>
@property (nonatomic, strong) NSButton *showGoogleQuickLinkButton;
@property (nonatomic, strong) NSButton *showEudicQuickLinkButton;
@property (nonatomic, strong) NSButton *showAppleDictionaryQuickLinkButton;
@property (nonatomic, strong) NSButton *showSettingQuickLinkButton;

@property (nonatomic, strong) NSView *separatorView2;

Expand Down Expand Up @@ -468,6 +469,9 @@ - (void)setupUI {
self.showAppleDictionaryQuickLinkButton = [NSButton checkboxWithTitle:showAppleDictionaryQuickLink target:self action:@selector(showAppleDictionaryQuickLinkButtonClicked:)];
[self.contentView addSubview:self.showAppleDictionaryQuickLinkButton];

NSString *showSettingQuickLink = NSLocalizedString(@"show_setting_quick_link", nil);
self.showSettingQuickLinkButton = [NSButton checkboxWithTitle:showSettingQuickLink target:self action:@selector(showSettingQuickLinkButtonClicked:)];
[self.contentView addSubview:self.showSettingQuickLinkButton];

NSView *separatorView2 = [[NSView alloc] init];
[self.contentView addSubview:separatorView2];
Expand Down Expand Up @@ -570,6 +574,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.hideMenuBarIconButton.mm_isOn = self.config.hideMenuBarIcon;
if (@available(macOS 13.0, *)) {
self.enableBetaNewAppButton.mm_isOn = self.config.enableBetaNewApp;
Expand Down Expand Up @@ -829,11 +834,16 @@ - (void)updateViewConstraints {
make.left.equalTo(self.showEudicQuickLinkButton);
make.top.equalTo(self.showEudicQuickLinkButton.mas_bottom).offset(self.verticalPadding);
}];


[self.showSettingQuickLinkButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.showAppleDictionaryQuickLinkButton);
make.top.equalTo(self.showAppleDictionaryQuickLinkButton.mas_bottom).offset(self.verticalPadding);
}];

[self.fontSizeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.autoGetSelectedTextLabel);
make.top.equalTo(self.showAppleDictionaryQuickLinkButton.mas_bottom).offset(20);
make.top.equalTo(self.showAppleDictionaryQuickLinkButton.mas_bottom).offset(20);
make.top.equalTo(self.showSettingQuickLinkButton.mas_bottom).offset(20);
make.top.equalTo(self.showSettingQuickLinkButton.mas_bottom).offset(20);
}];

CGFloat changeFontSizeViewWidth = 220;
Expand Down Expand Up @@ -1019,6 +1029,9 @@ - (void)showAppleDictionaryQuickLinkButtonClicked:(NSButton *)sender {
self.config.showAppleDictionaryQuickLink = sender.mm_isOn;
}

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

- (void)hideMenuBarIconButtonClicked:(NSButton *)sender {
// if user not set select shortcut and input shortcut not allow hidden menu bar icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import Foundation

extension Notification.Name {
static let serviceHasUpdated = Notification.Name(EZServiceHasUpdatedNotification)

static let openSettings = Notification.Name(EZOpenSettingsNotification)
}

@objc public extension NSNotification {
static let serviceHasUpdated = Notification.Name.serviceHasUpdated

static let openSettings = Notification.Name.openSettings
}
22 changes: 12 additions & 10 deletions Easydict/Feature/ViewController/Model/EZQueryModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,22 @@ - (NSString *)handleInputText:(NSString *)inputText {

_anchoredDraggable_State --> anchored Draggable State
*/
if ([queryText isSingleWord]) {
// If text is an English word, like LaTeX, we don't split it.
BOOL isEnglishWord = [EZAppleDictionary.shared queryDictionaryForText:queryText language:EZLanguageEnglish];
if (!isEnglishWord) {
// If text has quotes, like 'UIKit', we don't split it.
if ([queryText hasQuotesPair]) {
queryText = [queryText tryToRemoveQuotes];
} else {
queryText = [queryText splitCodeText];
if (Configuration.shared.automaticWordSegmentation) {
if ([queryText isSingleWord]) {
// If text is an English word, like LaTeX, we don't split it.
BOOL isEnglishWord = [EZAppleDictionary.shared queryDictionaryForText:queryText language:EZLanguageEnglish];
if (!isEnglishWord) {
// If text has quotes, like 'UIKit', we don't split it.
if ([queryText hasQuotesPair]) {
queryText = [queryText tryToRemoveQuotes];
} else {
queryText = [queryText splitCodeText];
}
}
}
}

if (Configuration.shared.beta) {
if (Configuration.shared.automaticallyRemoveCodeCommentSymbols) {
// Remove prefix [//,#,*,] and join texts.
queryText = [queryText removeCommentBlockSymbols];
NeverAgain11 marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
2 changes: 2 additions & 0 deletions Easydict/Feature/ViewController/View/Titlebar/EZTitlebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong) EZOpenLinkButton *favoriteButton;

@property (nonatomic, strong) EZOpenLinkButton *settingButton;

@end

NS_ASSUME_NONNULL_END
Loading