From 4fe33496c781031217ce5045d1f169ed0b23ecf4 Mon Sep 17 00:00:00 2001 From: FX Coudert Date: Tue, 25 Jan 2022 18:45:06 +0100 Subject: [PATCH] macOS: remove quitting badge (#2495) Co-authored-by: Charles Kerr --- macosx/BadgeView.h | 2 -- macosx/BadgeView.mm | 26 +++++--------------------- macosx/Badger.h | 1 - macosx/Badger.mm | 7 ------- macosx/Controller.mm | 2 -- 5 files changed, 5 insertions(+), 33 deletions(-) diff --git a/macosx/BadgeView.h b/macosx/BadgeView.h index a0d4fa980..1b6ddb5bf 100644 --- a/macosx/BadgeView.h +++ b/macosx/BadgeView.h @@ -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 diff --git a/macosx/BadgeView.mm b/macosx/BadgeView.mm index 8fdb5f7be..a2f20c8cc 100644 --- a/macosx/BadgeView.mm +++ b/macosx/BadgeView.mm @@ -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]; diff --git a/macosx/Badger.h b/macosx/Badger.h index b2d63aa67..17752a237 100644 --- a/macosx/Badger.h +++ b/macosx/Badger.h @@ -21,6 +21,5 @@ - (void)addCompletedTorrent:(Torrent*)torrent; - (void)removeTorrent:(Torrent*)torrent; - (void)clearCompleted; -- (void)setQuitting; @end diff --git a/macosx/Badger.mm b/macosx/Badger.mm index d934a8590..6c533f2e5 100644 --- a/macosx/Badger.mm +++ b/macosx/Badger.mm @@ -69,11 +69,4 @@ } } -- (void)setQuitting -{ - [self clearCompleted]; - [(BadgeView*)NSApp.dockTile.contentView setQuitting]; - [NSApp.dockTile display]; -} - @end diff --git a/macosx/Controller.mm b/macosx/Controller.mm index fb5913db9..a0b93d745 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -882,8 +882,6 @@ static void removeKeRangerRansomware() } } - [fBadger setQuitting]; - //remove all torrent downloads if (fPendingTorrentDownloads) {