cog/Playlist/StatusImageTransformer.m

63 lines
1.8 KiB
Matlab
Raw Normal View History

2008-02-22 13:27:24 +00:00
//
// StatusImageTransformer.m
// Cog
//
// Created by Vincent Spader on 2/21/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "StatusImageTransformer.h"
#import "PlaylistEntry.h"
@implementation StatusImageTransformer
@synthesize playImage;
@synthesize queueImage;
@synthesize errorImage;
@synthesize stopAfterImage;
+ (Class)transformedValueClass {
return [NSImage class];
}
+ (BOOL)allowsReverseTransformation {
return NO;
}
2008-02-22 13:27:24 +00:00
- (id)init {
self = [super init];
if(self) {
if(@available(macOS 11.0, *)) {
self.playImage = [NSImage imageWithSystemSymbolName:@"play.fill" accessibilityDescription:NSLocalizedString(@"PlayingTrackTooltip", "")];
self.queueImage = [NSImage imageWithSystemSymbolName:@"plus" accessibilityDescription:NSLocalizedString(@"QueuedTrackTooltip", "")];
self.errorImage = [NSImage imageWithSystemSymbolName:@"nosign" accessibilityDescription:NSLocalizedString(@"ErrorTrackTooltip", "")];
self.stopAfterImage = [NSImage imageWithSystemSymbolName:@"stop.fill" accessibilityDescription:NSLocalizedString(@"StopAfterTrackTooltip", "")];
} else {
self.playImage = [NSImage imageNamed:@"playTemplate"];
self.queueImage = [NSImage imageNamed:@"NSAddTemplate"];
self.errorImage = [NSImage imageNamed:@"NSStopProgressTemplate"];
self.stopAfterImage = [NSImage imageNamed:@"stopTemplate"];
}
}
return self;
}
2008-02-22 13:27:24 +00:00
// Convert from string to RepeatMode
- (id)transformedValue:(id)value {
if(value == nil) return nil;
2008-02-22 13:27:24 +00:00
if([value isEqualToString:@"playing"]) {
return self.playImage;
} else if([value isEqualToString:@"queued"]) {
return self.queueImage;
} else if([value isEqualToString:@"error"]) {
return self.errorImage;
} else if([value isEqualToString:@"stopAfter"]) {
return self.stopAfterImage;
}
2008-02-22 13:27:24 +00:00
return nil;
}
@end