mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
[macos] Delegate short name of app
This commit is contained in:
@ -45,6 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@protocol ASCExternalDelegate <NSObject>
|
||||
@optional
|
||||
- (NSString *)onApplicationName;
|
||||
- (NSString *)onApplicationNameShort;
|
||||
- (NSString *)onAppInfo:(NSString *)key;
|
||||
- (NSString *)onAppPreferredLanguage;
|
||||
- (NSString *)onCommercialInfo;
|
||||
|
||||
@ -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:)];
|
||||
|
||||
@ -53,4 +53,5 @@
|
||||
+ (NSString *)licensePath;
|
||||
+ (void)createCloudPath;
|
||||
+ (NSString *)appName;
|
||||
+ (NSString *)appNameShort;
|
||||
@end
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user