BathyScapheのアイコンセット生成&適用ツール
修订版 | da22ab8d2582bcb8c7f2b5d7b8a607ba483c6533 (tree) |
---|---|
时间 | 2012-05-30 22:32:58 |
作者 | masakih <masakih@user...> |
Commiter | masakih |
[Mod] カラーセットのUndoサポート
@@ -138,6 +138,10 @@ static NSArray *sThreadIdentifiers; | ||
138 | 138 | [nobinobi bind:@"middleImage" toObject:self withKeyPath:@"lastUpdatedHeaderMiddle.image" options:nil]; |
139 | 139 | [nobinobi bind:@"rightImage" toObject:self withKeyPath:@"lastUpdatedHeaderRight.image" options:nil]; |
140 | 140 | |
141 | + [colorSet addObserver:self forKeyPath:@"threadsListColor" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:colorSet]; | |
142 | + [colorSet addObserver:self forKeyPath:@"includeColors" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:colorSet]; | |
143 | + [colorSet addObserver:self forKeyPath:@"useStripe" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:colorSet]; | |
144 | + | |
141 | 145 | if( !wrapper ) { |
142 | 146 | wrapper = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:nil]; |
143 | 147 | } |
@@ -336,8 +340,6 @@ static NSArray *sThreadIdentifiers; | ||
336 | 340 | |
337 | 341 | if( plist ) { |
338 | 342 | [wrapper addFileWithPath:path]; |
339 | - | |
340 | - [self updateChangeCount:NSChangeDone]; | |
341 | 343 | } |
342 | 344 | } |
343 | 345 |
@@ -414,6 +416,27 @@ static NSArray *sThreadIdentifiers; | ||
414 | 416 | } |
415 | 417 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context |
416 | 418 | { |
419 | + if(object == colorSet) { | |
420 | + NSUndoManager *um = [self undoManager]; | |
421 | + if([keyPath isEqualToString:@"threadsListColor"]) { | |
422 | + id old = [change objectForKey:NSKeyValueChangeOldKey]; | |
423 | + if([old isEqual:[NSNull null]]) old = nil; | |
424 | + [[um prepareWithInvocationTarget:colorSet] setThreadsListColor:old]; | |
425 | + return; | |
426 | + } | |
427 | + | |
428 | + NSNumber *old = [change objectForKey:NSKeyValueChangeOldKey]; | |
429 | + NSNumber *new = [change objectForKey:NSKeyValueChangeNewKey]; | |
430 | + if([old isEqualToNumber:new]) return; | |
431 | + | |
432 | + if([keyPath isEqualToString:@"includeColors"]) { | |
433 | + [[um prepareWithInvocationTarget:colorSet] setIncludeColors:[old boolValue]]; | |
434 | + } else if([keyPath isEqualToString:@"useStripe"]) { | |
435 | + [[um prepareWithInvocationTarget:colorSet] setUseStripe:[old boolValue]]; | |
436 | + } | |
437 | + | |
438 | + return; | |
439 | + } | |
417 | 440 | if(![keyPath isEqual:BSCIImageFileWrapperKey]) return; |
418 | 441 | |
419 | 442 | NSFileWrapper *imageFileWrapper = [object valueForKey:keyPath]; |