Skip to content

Commit

Permalink
Merge branch 'dev' into phlpsong/service_tab_swiftui
Browse files Browse the repository at this point in the history
  • Loading branch information
phlpsong authored Jan 8, 2024
2 parents 2efd70d + 9433ee3 commit c3ba762
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
29 changes: 25 additions & 4 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -884,10 +884,24 @@
}
},
"Easydict" : {

"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : ""
}
}
}
},
"Easydict 🍃" : {

"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : ""
}
}
}
},
"enable_beta_new_app" : {
"localizations" : {
Expand Down Expand Up @@ -1420,7 +1434,7 @@
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"state" : "translated",
"value" : "请前往服务官网注册申请个人的 API key。"
}
}
Expand Down Expand Up @@ -2440,7 +2454,14 @@
}
},
"Tisfeng" : {

"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : ""
}
}
}
},
"toggle_languages" : {
"localizations" : {
Expand Down
22 changes: 0 additions & 22 deletions Easydict/Feature/StatusItem/EZMenuItemManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ - (void)setup {
self.versionItem.title = self.versionTitle;

NSArray *items = @[self.versionItem, self.settingsItem, self.checkForUpdateItem, self.helpItem, self.quitItem];
[self increaseMenuItemsHeight:items lineHeightRatio:kTitleMenuItemHeightRatio];

[self updateVersionItem];
}
Expand Down Expand Up @@ -308,8 +307,6 @@ - (void)menuWillOpen:(NSMenu *)menu {
item.keyEquivalent = @"";
item.keyEquivalentModifierMask = 0;
}

[self increaseMenuItemHeight:item lineHeightRatio:kImageMenuItemHeightRatio];
};

configItemShortcut(self.selectionItem, EZSelectionShortcutKey);
Expand All @@ -319,24 +316,6 @@ - (void)menuWillOpen:(NSMenu *)menu {
configItemShortcut(self.screenshotOCRItem, EZScreenshotOCRShortcutKey);
}

#pragma mark -

/// Increase menu item height. Ref: https://stackoverflow.com/questions/18031666/nsmenuitem-height
- (void)increaseMenuItemHeight:(NSMenuItem *)item lineHeightRatio:(CGFloat)lineHeightRatio {
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
CGFloat fontLineHeight = (font.ascender + fabs(font.descender));
CGFloat lineHeight = fontLineHeight * lineHeightRatio;
// Ref stackoverflow: https://stackoverflow.com/a/18034142/8378840
NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(1, lineHeight)];
[item setImage:image];
}

- (void)increaseMenuItemsHeight:(NSArray<NSMenuItem *> *)itmes lineHeightRatio:(CGFloat)lineHeightRatio {
for (NSMenuItem *item in itmes) {
[self increaseMenuItemHeight:item lineHeightRatio:lineHeightRatio];
}
}

#pragma mark - Fetch Github Repo Info

- (void)updateVersionItem {
Expand All @@ -347,7 +326,6 @@ - (void)updateVersionItem {
versionTitle = [NSString stringWithFormat:@"%@ (✨ %@)", self.versionTitle, lastestVersion];
}
self.versionItem.title = versionTitle;
[self increaseMenuItemHeight:self.versionItem lineHeightRatio:kTitleMenuItemHeightRatio];
}];
}

Expand Down

0 comments on commit c3ba762

Please sign in to comment.