Do not use OakFileIconImage for menu items and recent projects

On macOS 10.14 this image doesn’t always render, so this is a temporary workaround.

The main advantage of using OakFileIconImage is the added SCM badge and custom icon for known file types.
This commit is contained in:
Allan Odgaard
2018-10-31 00:52:26 +07:00
parent e7d87af3f5
commit e8a3cb8f57
2 changed files with 6 additions and 4 deletions

View File

@@ -1,7 +1,6 @@
#import "Favorites.h"
#import <OakFilterList/OakAbbreviations.h>
#import <OakAppKit/OakAppKit.h>
#import <OakAppKit/OakFileIconImage.h>
#import <OakAppKit/OakUIConstructionFunctions.h>
#import <OakAppKit/OakScopeBarView.h>
#import <OakAppKit/OakSound.h>
@@ -200,9 +199,13 @@ static NSUInteger const kOakSourceIndexFavorites = 1;
for(NSDictionary* item in items)
{
NSString* path = item[@"path"];
NSImage* image = [NSWorkspace.sharedWorkspace iconForFile:path];
image.size = NSMakeSize(32, 32);
NSMutableDictionary* tmp = [item mutableCopy];
[tmp addEntriesFromDictionary:@{
@"icon": [OakFileIconImage fileIconImageWithPath:path size:NSMakeSize(32, 32)],
@"icon": image,
@"name": item[@"name"] ?: [NSString stringWithCxxString:path::display_name(to_s(path))],
@"folder": item[@"folder"] ?: [[path stringByDeletingLastPathComponent] stringByAbbreviatingWithTildeInPath],
@"info": [path stringByAbbreviatingWithTildeInPath]

View File

@@ -1,5 +1,4 @@
#import "NSMenu Additions.h"
#import "OakFileIconImage.h"
#import <OakFoundation/OakFoundation.h>
#import <OakFoundation/NSString Additions.h>
#import <text/case.h>
@@ -117,7 +116,7 @@ static char const* kOakMenuItemTabTrigger = "OakMenuItemTabTrigger";
{
NSImage* icon = nil;
if([[NSFileManager defaultManager] fileExistsAtPath:path])
icon = [OakFileIconImage fileIconImageWithPath:path size:NSMakeSize(16, 16)];
icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
else if(OakNotEmptyString([path pathExtension]))
icon = [[NSWorkspace sharedWorkspace] iconForFileType:[path pathExtension]];
else