[macos] Delegate short name of app

This commit is contained in:
Alexander Yuzhin
2019-01-31 11:50:39 +03:00
parent 8f89a24097
commit 79f82de596
4 changed files with 24 additions and 1 deletions

View File

@ -45,6 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol ASCExternalDelegate <NSObject>
@optional
- (NSString *)onApplicationName;
- (NSString *)onApplicationNameShort;
- (NSString *)onAppInfo:(NSString *)key;
- (NSString *)onAppPreferredLanguage;
- (NSString *)onCommercialInfo;

View File

@ -244,7 +244,7 @@ NSString *tabScrubberItemIdentifier = @"tabItem";
self.onItemTap(self.startPageButton, kStartPageButtonIdentifier);
}
}];
_startPageButton = [NSButton buttonWithTitle:[ASCHelper appName]
_startPageButton = [NSButton buttonWithTitle:[ASCHelper appNameShort]
image:[NSImage imageNamed:@"touchbar-tab-startpage"]
target:blockHolder
action:@selector(invoke:)];

View File

@ -53,4 +53,5 @@
+ (NSString *)licensePath;
+ (void)createCloudPath;
+ (NSString *)appName;
+ (NSString *)appNameShort;
@end

View File

@ -145,4 +145,25 @@ static NSMutableDictionary * localSettings;
}
}
+ (NSString *)appNameShort {
id <ASCExternalDelegate> externalDelegate = [[ASCExternalController shared] delegate];
if (externalDelegate && [externalDelegate respondsToSelector:@selector(onApplicationNameShort)]) {
return [externalDelegate onApplicationNameShort];
} else {
CFBundleRef localInfoBundle = CFBundleGetMainBundle();
NSDictionary * localInfoDict = (NSDictionary *)CFBundleGetLocalInfoDictionary(localInfoBundle);
if (localInfoDict) {
NSString * productName = [localInfoDict objectForKey:@"CFBundleName"];
if (productName && productName.length > 0) {
return productName;
}
}
return [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleNameKey];
}
}
@end