From 2fddf05515de3850b350ba094d322b452f41d2e6 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 12 Sep 2014 15:06:51 +0200 Subject: [PATCH] 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. --- .../MacOSX/OwnCloudFinder/ContentManager.h | 2 ++ .../MacOSX/OwnCloudFinder/ContentManager.m | 33 +++++++++++-------- .../MacOSX/OwnCloudFinder/RequestManager.m | 3 ++ src/mirall/socketapi.cpp | 11 +++++++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h index 841d60fa1..2de92bc16 100644 --- a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h +++ b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.h @@ -42,4 +42,6 @@ - (void)reFetchFileNameCacheForPath:(NSString*)path; - (void)repaintAllWindows; +- (void)loadIconResourcePath:(NSString*)path; + @end \ No newline at end of file diff --git a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.m b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.m index 26b320fe0..5fd17dec6 100644 --- a/shell_integration/MacOSX/OwnCloudFinder/ContentManager.m +++ b/shell_integration/MacOSX/OwnCloudFinder/ContentManager.m @@ -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]; diff --git a/shell_integration/MacOSX/OwnCloudFinder/RequestManager.m b/shell_integration/MacOSX/OwnCloudFinder/RequestManager.m index 2b720b025..cc139c68f 100644 --- a/shell_integration/MacOSX/OwnCloudFinder/RequestManager.m +++ b/shell_integration/MacOSX/OwnCloudFinder/RequestManager.m @@ -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]); } diff --git a/src/mirall/socketapi.cpp b/src/mirall/socketapi.cpp index bb86ae6ae..aec40e25e 100644 --- a/src/mirall/socketapi.cpp +++ b/src/mirall/socketapi.cpp @@ -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); }