From d0beae2f14e4bc951aeef565cb040c3bf4ced9cb Mon Sep 17 00:00:00 2001 From: Mitch Livingston Date: Sun, 7 Jan 2024 13:27:48 -0500 Subject: [PATCH] Remove dead pre-Lion code from the torrent table view (#6501) With our current minimum version, all clients will be using the popover --- macosx/Base.lproj/MainMenu.xib | 125 ---------------------- macosx/TorrentTableView.h | 9 -- macosx/TorrentTableView.mm | 187 --------------------------------- 3 files changed, 321 deletions(-) diff --git a/macosx/Base.lproj/MainMenu.xib b/macosx/Base.lproj/MainMenu.xib index facef2bee..a5f4d0f38 100644 --- a/macosx/Base.lproj/MainMenu.xib +++ b/macosx/Base.lproj/MainMenu.xib @@ -421,15 +421,9 @@ - - - - - - @@ -1216,123 +1210,6 @@ CA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1342,8 +1219,6 @@ CA - - diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index 13418444d..b7facdb49 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -33,15 +33,6 @@ extern CGFloat const kGroupSeparatorHeight; - (IBAction)displayTorrentActionPopover:(id)sender; -- (IBAction)setQuickLimitMode:(id)sender; -- (void)setQuickLimit:(id)sender; -- (IBAction)setGlobalLimit:(id)sender; - -- (IBAction)setQuickRatioMode:(id)sender; -- (void)setQuickRatio:(id)sender; - -- (IBAction)setPriority:(id)sender; - - (void)togglePiecesBar; @property(nonatomic, readonly) CGFloat piecesBarPercent; diff --git a/macosx/TorrentTableView.mm b/macosx/TorrentTableView.mm index c137b6e46..54af6cc07 100644 --- a/macosx/TorrentTableView.mm +++ b/macosx/TorrentTableView.mm @@ -26,19 +26,6 @@ CGFloat const kGroupSeparatorHeight = 18.0; static NSInteger const kMaxGroup = 999999; static CGFloat const kErrorImageSize = 20.0; -//eliminate when Lion-only -typedef NS_ENUM(NSUInteger, ActionMenuTag) { - ActionMenuTagGlobal = 101, - ActionMenuTagUnlimited = 102, - ActionMenuTagLimit = 103, -}; - -typedef NS_ENUM(NSUInteger, ActionMenuPriorityTag) { - ActionMenuPriorityTagHigh = 101, - ActionMenuPriorityTagNormal = 102, - ActionMenuPriorityTagLow = 103, -}; - static NSTimeInterval const kToggleProgressSeconds = 0.175; @interface TorrentTableView () @@ -54,14 +41,6 @@ static NSTimeInterval const kToggleProgressSeconds = 0.175; @property(nonatomic) NSIndexSet* fSelectedRowIndexes; -@property(nonatomic) IBOutlet NSMenu* fActionMenu; -@property(nonatomic) IBOutlet NSMenu* fUploadMenu; -@property(nonatomic) IBOutlet NSMenu* fDownloadMenu; -@property(nonatomic) IBOutlet NSMenu* fRatioMenu; -@property(nonatomic) IBOutlet NSMenu* fPriorityMenu; -@property(nonatomic) IBOutlet NSMenuItem* fGlobalLimitItem; -@property(nonatomic, readonly) Torrent* fMenuTorrent; - @property(nonatomic) CGFloat piecesBarPercent; @property(nonatomic) NSAnimation* fPiecesBarAnimation; @@ -873,172 +852,6 @@ static NSTimeInterval const kToggleProgressSeconds = 0.175; self.fActionPopoverShown = NO; } -//eliminate when Lion-only, along with all the menu item instance variables -- (void)menuNeedsUpdate:(NSMenu*)menu -{ - //this method seems to be called when it shouldn't be - if (!self.fMenuTorrent || !menu.supermenu) - { - return; - } - - if (menu == self.fUploadMenu || menu == self.fDownloadMenu) - { - NSMenuItem* item; - if (menu.numberOfItems == 3) - { - static NSArray* const speedLimitActionValues = @[ @50, @100, @250, @500, @1000, @2500, @5000, @10000 ]; - - for (NSNumber* i in speedLimitActionValues) - { - item = [[NSMenuItem alloc] - initWithTitle:[NSString localizedStringWithFormat:NSLocalizedString(@"%ld KB/s", "Action menu -> upload/download limit"), - i.integerValue] - action:@selector(setQuickLimit:) - keyEquivalent:@""]; - item.target = self; - item.representedObject = i; - [menu addItem:item]; - } - } - - BOOL const upload = menu == self.fUploadMenu; - BOOL const limit = [self.fMenuTorrent usesSpeedLimit:upload]; - - item = [menu itemWithTag:ActionMenuTagLimit]; - item.state = limit ? NSControlStateValueOn : NSControlStateValueOff; - item.title = [NSString localizedStringWithFormat:NSLocalizedString(@"Limit (%ld KB/s)", "torrent action menu -> upload/download limit"), - [self.fMenuTorrent speedLimit:upload]]; - - item = [menu itemWithTag:ActionMenuTagUnlimited]; - item.state = !limit ? NSControlStateValueOn : NSControlStateValueOff; - } - else if (menu == self.fRatioMenu) - { - NSMenuItem* item; - if (menu.numberOfItems == 4) - { - static NSArray* const ratioLimitActionValue = @[ @0.25, @0.5, @0.75, @1.0, @1.5, @2.0, @3.0 ]; - - for (NSNumber* i in ratioLimitActionValue) - { - item = [[NSMenuItem alloc] initWithTitle:[NSString localizedStringWithFormat:@"%.2f", i.floatValue] - action:@selector(setQuickRatio:) - keyEquivalent:@""]; - item.target = self; - item.representedObject = i; - [menu addItem:item]; - } - } - - tr_ratiolimit const mode = self.fMenuTorrent.ratioSetting; - - item = [menu itemWithTag:ActionMenuTagLimit]; - item.state = mode == TR_RATIOLIMIT_SINGLE ? NSControlStateValueOn : NSControlStateValueOff; - item.title = [NSString localizedStringWithFormat:NSLocalizedString(@"Stop at Ratio (%.2f)", "torrent action menu -> ratio stop"), - self.fMenuTorrent.ratioLimit]; - - item = [menu itemWithTag:ActionMenuTagUnlimited]; - item.state = mode == TR_RATIOLIMIT_UNLIMITED ? NSControlStateValueOn : NSControlStateValueOff; - - item = [menu itemWithTag:ActionMenuTagGlobal]; - item.state = mode == TR_RATIOLIMIT_GLOBAL ? NSControlStateValueOn : NSControlStateValueOff; - } - else if (menu == self.fPriorityMenu) - { - tr_priority_t const priority = self.fMenuTorrent.priority; - - NSMenuItem* item = [menu itemWithTag:ActionMenuPriorityTagHigh]; - item.state = priority == TR_PRI_HIGH ? NSControlStateValueOn : NSControlStateValueOff; - - item = [menu itemWithTag:ActionMenuPriorityTagNormal]; - item.state = priority == TR_PRI_NORMAL ? NSControlStateValueOn : NSControlStateValueOff; - - item = [menu itemWithTag:ActionMenuPriorityTagLow]; - item.state = priority == TR_PRI_LOW ? NSControlStateValueOn : NSControlStateValueOff; - } -} - -//the following methods might not be needed when Lion-only -- (void)setQuickLimitMode:(id)sender -{ - BOOL const limit = [sender tag] == ActionMenuTagLimit; - [self.fMenuTorrent setUseSpeedLimit:limit upload:[sender menu] == self.fUploadMenu]; - - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptions" object:nil]; -} - -- (void)setQuickLimit:(id)sender -{ - BOOL const upload = [sender menu] == self.fUploadMenu; - [self.fMenuTorrent setUseSpeedLimit:YES upload:upload]; - [self.fMenuTorrent setSpeedLimit:[[sender representedObject] intValue] upload:upload]; - - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptions" object:nil]; -} - -- (void)setGlobalLimit:(id)sender -{ - self.fMenuTorrent.usesGlobalSpeedLimit = ((NSButton*)sender).state != NSControlStateValueOn; - - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptions" object:nil]; -} - -- (void)setQuickRatioMode:(id)sender -{ - tr_ratiolimit mode; - switch ([sender tag]) - { - case ActionMenuTagUnlimited: - mode = TR_RATIOLIMIT_UNLIMITED; - break; - case ActionMenuTagLimit: - mode = TR_RATIOLIMIT_SINGLE; - break; - case ActionMenuTagGlobal: - mode = TR_RATIOLIMIT_GLOBAL; - break; - default: - return; - } - - self.fMenuTorrent.ratioSetting = mode; - - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptions" object:nil]; -} - -- (void)setQuickRatio:(id)sender -{ - self.fMenuTorrent.ratioSetting = TR_RATIOLIMIT_SINGLE; - self.fMenuTorrent.ratioLimit = [[sender representedObject] floatValue]; - - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptions" object:nil]; -} - -- (void)setPriority:(id)sender -{ - tr_priority_t priority; - switch ([sender tag]) - { - case ActionMenuPriorityTagHigh: - priority = TR_PRI_HIGH; - break; - case ActionMenuPriorityTagNormal: - priority = TR_PRI_NORMAL; - break; - case ActionMenuPriorityTagLow: - priority = TR_PRI_LOW; - break; - default: - NSAssert1(NO, @"Unknown priority: %ld", [sender tag]); - priority = TR_PRI_NORMAL; - } - - self.fMenuTorrent.priority = priority; - - [NSNotificationCenter.defaultCenter postNotificationName:@"UpdateUI" object:nil]; -} - - (void)togglePiecesBar { NSMutableArray* progressMarks = [NSMutableArray arrayWithCapacity:16];