mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 14:36:01 +03:00
OS X: Overlay Icons: Load from bundle-specific path
The client (in this case mirall) tells the Finder plugin where to get the icons. This enables installation in different locations and in branded clients.
This commit is contained in:
parent
91d1864840
commit
2fddf05515
4 changed files with 36 additions and 13 deletions
|
@ -42,4 +42,6 @@
|
|||
- (void)reFetchFileNameCacheForPath:(NSString*)path;
|
||||
- (void)repaintAllWindows;
|
||||
|
||||
- (void)loadIconResourcePath:(NSString*)path;
|
||||
|
||||
@end
|
|
@ -32,19 +32,6 @@ static ContentManager* sharedInstance = nil;
|
|||
_fileNamesCache = [[NSMutableDictionary alloc] init];
|
||||
_fileIconsEnabled = TRUE;
|
||||
_hasChangedContent = TRUE;
|
||||
|
||||
NSString *base = @"/Applications/owncloud.app/Contents/Resources/icons/";
|
||||
|
||||
_icnOk = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"ok.icns"]];
|
||||
_icnSync = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"sync.icns"]];
|
||||
_icnWarn = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"warning.icns"]];
|
||||
_icnErr = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"error.icns"]];
|
||||
_icnOkSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"ok_swm.icns"]];
|
||||
_icnSyncSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"sync_swm.icns"]];
|
||||
_icnWarnSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"warning_swm.icns"]];
|
||||
_icnErrSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"error_swm.icns"]];
|
||||
|
||||
NSLog(@"Icon ok identifier: %d", [_icnOk intValue]);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -72,6 +59,22 @@ static ContentManager* sharedInstance = nil;
|
|||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (void)loadIconResourcePath:(NSString*)path
|
||||
{
|
||||
NSString *base = path;
|
||||
|
||||
_icnOk = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"ok.icns"]];
|
||||
_icnSync = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"sync.icns"]];
|
||||
_icnWarn = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"warning.icns"]];
|
||||
_icnErr = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"error.icns"]];
|
||||
_icnOkSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"ok_swm.icns"]];
|
||||
_icnSyncSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"sync_swm.icns"]];
|
||||
_icnWarnSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"warning_swm.icns"]];
|
||||
_icnErrSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingString:@"error_swm.icns"]];
|
||||
|
||||
NSLog(@"Icon ok identifier: %d from %@", [_icnOk intValue], [base stringByAppendingString:@"ok.icns"]);
|
||||
}
|
||||
|
||||
- (void)enableFileIcons:(BOOL)enable
|
||||
{
|
||||
_fileIconsEnabled = enable;
|
||||
|
@ -81,6 +84,10 @@ static ContentManager* sharedInstance = nil;
|
|||
|
||||
- (void)setResultForPath:(NSString*)path result:(NSString*)result
|
||||
{
|
||||
if (_icnOk == nil) {
|
||||
// no icon resource path registered yet
|
||||
return;
|
||||
}
|
||||
|
||||
NSNumber *res;
|
||||
res = [NSNumber numberWithInt:0];
|
||||
|
|
|
@ -149,6 +149,9 @@ static RequestManager* sharedInstance = nil;
|
|||
[_registeredPathes removeObjectForKey:path];
|
||||
|
||||
[contentman repaintAllWindows];
|
||||
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"ICON_PATH"] ) {
|
||||
NSString *path = [chunks objectAtIndex:1];
|
||||
[[ContentManager sharedInstance] loadIconResourcePath:path];
|
||||
} else {
|
||||
NSLog(@"Unknown command %@", [chunks objectAtIndex:0]);
|
||||
}
|
||||
|
|
|
@ -246,6 +246,17 @@ void SocketApi::slotNewConnection()
|
|||
|
||||
_listeners.append(socket);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
// We want to tell our location so it can load the icons
|
||||
// e.g. "/Users/guruz/woboq/owncloud/client/buildmirall/owncloud.app/Contents/MacOS/"
|
||||
QString iconPath = qApp->applicationDirPath() + "/../Resources/icons/";
|
||||
if (!QDir(iconPath).exists()) {
|
||||
DEBUG << "Icon path " << iconPath << " does not exist, did you forget make install?";
|
||||
}
|
||||
broadcastMessage(QLatin1String("ICON_PATH"), iconPath );
|
||||
#endif
|
||||
|
||||
|
||||
foreach( QString alias, FolderMan::instance()->map().keys() ) {
|
||||
slotRegisterPath(alias);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue