update filter correctly when switching from waiting to check state to seeding
This commit is contained in:
parent
0adeb9b2f6
commit
90f9a9c716
|
@ -1676,10 +1676,16 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
[tempTorrents setArray: fTorrents];
|
[tempTorrents setArray: fTorrents];
|
||||||
|
|
||||||
//set buttons with counts
|
//set buttons with counts
|
||||||
[fNoFilterButton setCount: [fTorrents count]];
|
BOOL change = NO;
|
||||||
[fDownloadFilterButton setCount: downloading];
|
if ([fNoFilterButton setCount: [fTorrents count]])
|
||||||
[fSeedFilterButton setCount: seeding];
|
change = YES;
|
||||||
[fPauseFilterButton setCount: paused];
|
if ([fDownloadFilterButton setCount: downloading])
|
||||||
|
change = YES;
|
||||||
|
if ([fSeedFilterButton setCount: seeding])
|
||||||
|
change = YES;
|
||||||
|
if ([fPauseFilterButton setCount: paused])
|
||||||
|
change = YES;
|
||||||
|
if (change)
|
||||||
[fFilterBar replaceButtons];
|
[fFilterBar replaceButtons];
|
||||||
|
|
||||||
NSString * searchString = [fSearchFilterField stringValue];
|
NSString * searchString = [fSearchFilterField stringValue];
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
NSTrackingRectTag fTrackingTag;
|
NSTrackingRectTag fTrackingTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setCount: (int) count;
|
- (BOOL) setCount: (int) count;
|
||||||
- (void) setEnabled: (BOOL) enable;
|
- (void) setEnabled: (BOOL) enable;
|
||||||
|
|
||||||
- (void) resetBounds: (NSNotification *) notification;
|
- (void) resetBounds: (NSNotification *) notification;
|
||||||
|
|
|
@ -25,6 +25,12 @@
|
||||||
#import "FilterBarButton.h"
|
#import "FilterBarButton.h"
|
||||||
#import "StringAdditions.h"
|
#import "StringAdditions.h"
|
||||||
|
|
||||||
|
@interface FilterBarButton (Private)
|
||||||
|
|
||||||
|
- (NSImage *) badgeCount: (int) count color: (NSColor *) color;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation FilterBarButton
|
@implementation FilterBarButton
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *) coder
|
- (id) initWithCoder: (NSCoder *) coder
|
||||||
|
@ -64,46 +70,10 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSImage *) badgeCount: (int) count color: (NSColor *) color
|
- (BOOL) setCount: (int) count
|
||||||
{
|
|
||||||
NSDictionary * attributes = [[NSDictionary alloc] initWithObjectsAndKeys:
|
|
||||||
[[NSFontManager sharedFontManager] convertFont: [NSFont fontWithName: @"Lucida Grande" size: 10.0]
|
|
||||||
toHaveTrait: NSBoldFontMask], NSFontAttributeName, nil];
|
|
||||||
|
|
||||||
NSString * string = [NSString stringWithInt: count];
|
|
||||||
NSSize stringSize = [string sizeWithAttributes: attributes];
|
|
||||||
NSRect badgeRect = NSMakeRect(0, 0, stringSize.width + 6.0, stringSize.height);
|
|
||||||
|
|
||||||
//create badge part
|
|
||||||
NSImage * tempBadge = [[NSImage alloc] initWithSize: badgeRect.size];
|
|
||||||
NSBezierPath * bp = [NSBezierPath bezierPathWithOvalInRect: badgeRect];
|
|
||||||
[tempBadge lockFocus];
|
|
||||||
|
|
||||||
[color set];
|
|
||||||
[bp fill];
|
|
||||||
|
|
||||||
[tempBadge unlockFocus];
|
|
||||||
|
|
||||||
//create string part
|
|
||||||
NSImage * badge = [[NSImage alloc] initWithSize: badgeRect.size];
|
|
||||||
[badge lockFocus];
|
|
||||||
|
|
||||||
[string drawAtPoint: NSMakePoint((badgeRect.size.width - stringSize.width) * 0.5,
|
|
||||||
(badgeRect.size.height - stringSize.height) * 0.5) withAttributes: attributes];
|
|
||||||
[tempBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOut];
|
|
||||||
|
|
||||||
[badge unlockFocus];
|
|
||||||
|
|
||||||
[tempBadge release];
|
|
||||||
[attributes release];
|
|
||||||
|
|
||||||
return [badge autorelease];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setCount: (int) count
|
|
||||||
{
|
{
|
||||||
if (fCount == count)
|
if (fCount == count)
|
||||||
return;
|
return NO;
|
||||||
fCount = count;
|
fCount = count;
|
||||||
|
|
||||||
if (fButtonNormal)
|
if (fButtonNormal)
|
||||||
|
@ -333,6 +303,8 @@
|
||||||
[self setImage: fEnabled ? fButtonSelected : fButtonNormal];
|
[self setImage: fEnabled ? fButtonSelected : fButtonNormal];
|
||||||
else
|
else
|
||||||
[self setImage: fEnabled ? fButtonSelectedDim : fButtonNormalDim];
|
[self setImage: fEnabled ? fButtonSelectedDim : fButtonNormalDim];
|
||||||
|
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) mouseEntered: (NSEvent *) event
|
- (void) mouseEntered: (NSEvent *) event
|
||||||
|
@ -382,3 +354,43 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation FilterBarButton (Private)
|
||||||
|
|
||||||
|
- (NSImage *) badgeCount: (int) count color: (NSColor *) color
|
||||||
|
{
|
||||||
|
NSDictionary * attributes = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
|
[[NSFontManager sharedFontManager] convertFont: [NSFont fontWithName: @"Lucida Grande" size: 10.0]
|
||||||
|
toHaveTrait: NSBoldFontMask], NSFontAttributeName, nil];
|
||||||
|
|
||||||
|
NSString * string = [NSString stringWithInt: count];
|
||||||
|
NSSize stringSize = [string sizeWithAttributes: attributes];
|
||||||
|
NSRect badgeRect = NSMakeRect(0, 0, stringSize.width + 6.0, stringSize.height);
|
||||||
|
|
||||||
|
//create badge part
|
||||||
|
NSImage * tempBadge = [[NSImage alloc] initWithSize: badgeRect.size];
|
||||||
|
NSBezierPath * bp = [NSBezierPath bezierPathWithOvalInRect: badgeRect];
|
||||||
|
[tempBadge lockFocus];
|
||||||
|
|
||||||
|
[color set];
|
||||||
|
[bp fill];
|
||||||
|
|
||||||
|
[tempBadge unlockFocus];
|
||||||
|
|
||||||
|
//create string part
|
||||||
|
NSImage * badge = [[NSImage alloc] initWithSize: badgeRect.size];
|
||||||
|
[badge lockFocus];
|
||||||
|
|
||||||
|
[string drawAtPoint: NSMakePoint((badgeRect.size.width - stringSize.width) * 0.5,
|
||||||
|
(badgeRect.size.height - stringSize.height) * 0.5) withAttributes: attributes];
|
||||||
|
[tempBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOut];
|
||||||
|
|
||||||
|
[badge unlockFocus];
|
||||||
|
|
||||||
|
[tempBadge release];
|
||||||
|
[attributes release];
|
||||||
|
|
||||||
|
return [badge autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
|
@ -381,6 +381,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
[shortStatusString setString: tempString];
|
[shortStatusString setString: tempString];
|
||||||
[remainingTimeString setString: tempString];
|
[remainingTimeString setString: tempString];
|
||||||
|
|
||||||
|
fChecking = YES;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TR_STATUS_CHECK:
|
case TR_STATUS_CHECK:
|
||||||
|
|
Loading…
Reference in New Issue