mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
more consistent dock badging
This commit is contained in:
parent
69c6a9b40b
commit
f212862a17
2 changed files with 9 additions and 23 deletions
|
@ -30,9 +30,7 @@
|
|||
@interface Badger : NSObject {
|
||||
|
||||
NSImage * fDockIcon, * fBadge, * fUploadBadge, * fDownloadBadge;
|
||||
|
||||
NSDictionary * fAttributes;
|
||||
BOOL fNonDefault;
|
||||
}
|
||||
|
||||
- (void) updateBadgeWithCompleted: (int) completed uploadRate: (float) uploadRate downloadRate: (float) downloadRate;
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
fBadge = [NSImage imageNamed: @"Badge"];
|
||||
fDockIcon = [[NSApp applicationIconImage] copy];
|
||||
fBadge = [NSImage imageNamed: @"Badge"];
|
||||
fUploadBadge = [NSImage imageNamed: @"UploadBadge"];
|
||||
fDownloadBadge = [NSImage imageNamed: @"DownloadBadge"];
|
||||
|
||||
|
@ -54,8 +54,6 @@
|
|||
boldFont, NSFontAttributeName, stringShadow, NSShadowAttributeName, nil];
|
||||
|
||||
[stringShadow release];
|
||||
|
||||
fNonDefault = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -71,9 +69,8 @@
|
|||
|
||||
- (void) updateBadgeWithCompleted: (int) completed uploadRate: (float) uploadRate downloadRate: (float) downloadRate
|
||||
{
|
||||
NSImage * dockIcon;
|
||||
NSSize iconSize = [fDockIcon size];
|
||||
|
||||
NSImage * dockIcon = nil;
|
||||
|
||||
//set completed badge to top right
|
||||
if (completed > 0)
|
||||
|
@ -108,8 +105,7 @@
|
|||
* downloadRateString = downloadRate >= 0.1 && [defaults boolForKey: @"BadgeDownloadRate"]
|
||||
? [NSString stringForSpeedAbbrev: downloadRate] : nil;
|
||||
|
||||
BOOL speedShown = uploadRateString || downloadRateString;
|
||||
if (speedShown)
|
||||
if (uploadRateString || downloadRateString)
|
||||
{
|
||||
if (!dockIcon)
|
||||
dockIcon = [fDockIcon copy];
|
||||
|
@ -155,25 +151,17 @@
|
|||
[dockIcon unlockFocus];
|
||||
}
|
||||
|
||||
if (fNonDefault || dockIcon)
|
||||
{
|
||||
if (!dockIcon)
|
||||
{
|
||||
fNonDefault = NO;
|
||||
dockIcon = [fDockIcon retain];
|
||||
}
|
||||
else
|
||||
fNonDefault = YES;
|
||||
|
||||
[NSApp setApplicationIconImage: dockIcon];
|
||||
[dockIcon release];
|
||||
}
|
||||
//update dock badge
|
||||
if (!dockIcon)
|
||||
dockIcon = [fDockIcon retain];
|
||||
|
||||
[NSApp setApplicationIconImage: dockIcon];
|
||||
[dockIcon release];
|
||||
}
|
||||
|
||||
- (void) clearBadge
|
||||
{
|
||||
[NSApp setApplicationIconImage: fDockIcon];
|
||||
fNonDefault = NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue