mirror of
https://github.com/transmission/transmission
synced 2025-02-07 06:54:40 +00:00
macOS: remove quitting badge (#2495)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
020a9e45ae
commit
4fe33496c7
5 changed files with 5 additions and 33 deletions
|
@ -14,12 +14,10 @@
|
|||
|
||||
CGFloat fDownloadRate;
|
||||
CGFloat fUploadRate;
|
||||
BOOL fQuitting;
|
||||
}
|
||||
|
||||
- (instancetype)initWithLib:(tr_session*)lib;
|
||||
|
||||
- (BOOL)setRatesWithDownload:(CGFloat)downloadRate upload:(CGFloat)uploadRate;
|
||||
- (void)setQuitting;
|
||||
|
||||
@end
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
@interface BadgeView ()
|
||||
|
||||
- (void)badge:(NSImage*)badge string:(NSString*)string atHeight:(CGFloat)height adjustForQuit:(BOOL)quit;
|
||||
- (void)badge:(NSImage*)badge string:(NSString*)string atHeight:(CGFloat)height;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
|||
|
||||
fDownloadRate = 0.0;
|
||||
fUploadRate = 0.0;
|
||||
fQuitting = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -41,31 +40,17 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void)setQuitting
|
||||
{
|
||||
fQuitting = YES;
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)rect
|
||||
{
|
||||
[NSApp.applicationIconImage drawInRect:rect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0];
|
||||
|
||||
if (fQuitting)
|
||||
{
|
||||
NSImage* quitBadge = [NSImage imageNamed:@"QuitBadge"];
|
||||
[self badge:quitBadge string:NSLocalizedString(@"Quitting", "Dock Badger -> quit")
|
||||
atHeight:(NSHeight(rect) - quitBadge.size.height) * 0.5
|
||||
adjustForQuit:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL const upload = fUploadRate >= 0.1;
|
||||
BOOL const download = fDownloadRate >= 0.1;
|
||||
CGFloat bottom = 0.0;
|
||||
if (upload)
|
||||
{
|
||||
NSImage* uploadBadge = [NSImage imageNamed:@"UploadBadge"];
|
||||
[self badge:uploadBadge string:[NSString stringForSpeedAbbrev:fUploadRate] atHeight:bottom adjustForQuit:NO];
|
||||
[self badge:uploadBadge string:[NSString stringForSpeedAbbrev:fUploadRate] atHeight:bottom];
|
||||
if (download)
|
||||
{
|
||||
bottom += uploadBadge.size.height + BETWEEN_PADDING; //download rate above upload rate
|
||||
|
@ -73,12 +58,11 @@
|
|||
}
|
||||
if (download)
|
||||
{
|
||||
[self badge:[NSImage imageNamed:@"DownloadBadge"] string:[NSString stringForSpeedAbbrev:fDownloadRate] atHeight:bottom
|
||||
adjustForQuit:NO];
|
||||
[self badge:[NSImage imageNamed:@"DownloadBadge"] string:[NSString stringForSpeedAbbrev:fDownloadRate] atHeight:bottom];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)badge:(NSImage*)badge string:(NSString*)string atHeight:(CGFloat)height adjustForQuit:(BOOL)quit
|
||||
- (void)badge:(NSImage*)badge string:(NSString*)string atHeight:(CGFloat)height
|
||||
{
|
||||
if (!fAttributes)
|
||||
{
|
||||
|
@ -111,7 +95,7 @@
|
|||
//string is in center of image
|
||||
NSRect stringRect;
|
||||
stringRect.origin.x = NSMidX(badgeRect) - stringSize.width * 0.5;
|
||||
stringRect.origin.y = NSMidY(badgeRect) - stringSize.height * 0.5 + (quit ? 2.0 : 1.0); //adjust for shadow, extra for quit
|
||||
stringRect.origin.y = NSMidY(badgeRect) - stringSize.height * 0.5 + 1.0; //adjust for shadow
|
||||
stringRect.size = stringSize;
|
||||
|
||||
[string drawInRect:stringRect withAttributes:fAttributes];
|
||||
|
|
|
@ -21,6 +21,5 @@
|
|||
- (void)addCompletedTorrent:(Torrent*)torrent;
|
||||
- (void)removeTorrent:(Torrent*)torrent;
|
||||
- (void)clearCompleted;
|
||||
- (void)setQuitting;
|
||||
|
||||
@end
|
||||
|
|
|
@ -69,11 +69,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setQuitting
|
||||
{
|
||||
[self clearCompleted];
|
||||
[(BadgeView*)NSApp.dockTile.contentView setQuitting];
|
||||
[NSApp.dockTile display];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -882,8 +882,6 @@ static void removeKeRangerRansomware()
|
|||
}
|
||||
}
|
||||
|
||||
[fBadger setQuitting];
|
||||
|
||||
//remove all torrent downloads
|
||||
if (fPendingTorrentDownloads)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue