2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2010-2022 Transmission authors and contributors.
|
|
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2010-03-06 23:12:30 +00:00
|
|
|
|
|
|
|
#import "InfoOptionsViewController.h"
|
2011-02-12 03:13:14 +00:00
|
|
|
#import "NSStringAdditions.h"
|
2010-03-06 23:12:30 +00:00
|
|
|
#import "Torrent.h"
|
|
|
|
|
|
|
|
#define OPTION_POPUP_GLOBAL 0
|
|
|
|
#define OPTION_POPUP_NO_LIMIT 1
|
|
|
|
#define OPTION_POPUP_LIMIT 2
|
|
|
|
|
|
|
|
#define OPTION_POPUP_PRIORITY_HIGH 0
|
|
|
|
#define OPTION_POPUP_PRIORITY_NORMAL 1
|
|
|
|
#define OPTION_POPUP_PRIORITY_LOW 2
|
|
|
|
|
|
|
|
#define INVALID -99
|
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
@interface InfoOptionsViewController ()
|
|
|
|
|
|
|
|
@property(nonatomic, copy) NSArray* fTorrents;
|
|
|
|
|
|
|
|
@property(nonatomic) BOOL fSet;
|
|
|
|
|
|
|
|
@property(nonatomic) IBOutlet NSPopUpButton* fPriorityPopUp;
|
|
|
|
@property(nonatomic) IBOutlet NSPopUpButton* fRatioPopUp;
|
|
|
|
@property(nonatomic) IBOutlet NSPopUpButton* fIdlePopUp;
|
|
|
|
@property(nonatomic) IBOutlet NSButton* fUploadLimitCheck;
|
|
|
|
@property(nonatomic) IBOutlet NSButton* fDownloadLimitCheck;
|
|
|
|
@property(nonatomic) IBOutlet NSButton* fGlobalLimitCheck;
|
|
|
|
@property(nonatomic) IBOutlet NSButton* fRemoveSeedingCompleteCheck;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fUploadLimitField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fDownloadLimitField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fRatioLimitField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fIdleLimitField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fUploadLimitLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fDownloadLimitLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fIdleLimitLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fRatioLimitGlobalLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fIdleLimitGlobalLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fPeersConnectLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fPeersConnectField;
|
|
|
|
|
|
|
|
//remove when we switch to auto layout
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fTransferBandwidthSectionLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fPrioritySectionLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fPriorityLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fSeedingLimitsSectionLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fRatioLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fInactivityLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fAdvancedSectionLabel;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fMaxConnectionsLabel;
|
|
|
|
|
|
|
|
@property(nonatomic, copy) NSString* fInitialString;
|
2010-03-09 02:26:52 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setupInfo;
|
|
|
|
- (void)setGlobalLabels;
|
|
|
|
- (void)updateOptionsNotification:(NSNotification*)notification;
|
2010-03-09 02:26:52 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
@implementation InfoOptionsViewController
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (instancetype)init
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
if ((self = [super initWithNibName:@"InfoOptionsView" bundle:nil]))
|
2010-03-14 03:09:12 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
self.title = NSLocalizedString(@"Options", "Inspector view -> title");
|
2010-03-14 03:09:12 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)awakeFromNib
|
2011-02-12 03:28:36 +00:00
|
|
|
{
|
|
|
|
[self setGlobalLabels];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(setGlobalLabels) name:@"UpdateGlobalOptions" object:nil];
|
|
|
|
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateOptionsNotification:)
|
|
|
|
name:@"UpdateOptionsNotification"
|
|
|
|
object:nil];
|
2011-02-12 03:28:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)dealloc
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter removeObserver:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setInfoForTorrents:(NSArray*)torrents
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2010-04-17 18:44:34 +00:00
|
|
|
//don't check if it's the same in case the metadata changed
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fTorrents = torrents;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fSet = NO;
|
2010-03-09 02:26:52 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)updateInfo
|
2010-03-09 02:26:52 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
if (!self.fSet)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-09 02:26:52 +00:00
|
|
|
[self setupInfo];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fSet = YES;
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)updateOptions
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
if (self.fTorrents.count == 0)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
return;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//get bandwidth info
|
2022-02-22 16:04:20 +00:00
|
|
|
NSEnumerator* enumerator = [self.fTorrents objectEnumerator];
|
2021-08-15 09:41:48 +00:00
|
|
|
Torrent* torrent = [enumerator nextObject]; //first torrent
|
|
|
|
|
2021-10-31 15:18:27 +00:00
|
|
|
NSInteger uploadUseSpeedLimit = [torrent usesSpeedLimit:YES] ? NSControlStateValueOn : NSControlStateValueOff;
|
2021-08-15 09:41:48 +00:00
|
|
|
NSInteger uploadSpeedLimit = [torrent speedLimit:YES];
|
2021-10-31 15:18:27 +00:00
|
|
|
NSInteger downloadUseSpeedLimit = [torrent usesSpeedLimit:NO] ? NSControlStateValueOn : NSControlStateValueOff;
|
2021-08-15 09:41:48 +00:00
|
|
|
NSInteger downloadSpeedLimit = [torrent speedLimit:NO];
|
2021-10-31 15:18:27 +00:00
|
|
|
NSInteger globalUseSpeedLimit = torrent.usesGlobalSpeedLimit ? NSControlStateValueOn : NSControlStateValueOff;
|
2021-08-15 09:41:48 +00:00
|
|
|
|
|
|
|
while ((torrent = [enumerator nextObject]) &&
|
2021-10-31 15:18:27 +00:00
|
|
|
(uploadUseSpeedLimit != NSControlStateValueMixed || uploadSpeedLimit != INVALID ||
|
|
|
|
downloadUseSpeedLimit != NSControlStateValueMixed || downloadSpeedLimit != INVALID ||
|
|
|
|
globalUseSpeedLimit != NSControlStateValueMixed))
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
if (uploadUseSpeedLimit != NSControlStateValueMixed &&
|
|
|
|
uploadUseSpeedLimit != ([torrent usesSpeedLimit:YES] ? NSControlStateValueOn : NSControlStateValueOff))
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
uploadUseSpeedLimit = NSControlStateValueMixed;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
if (uploadSpeedLimit != INVALID && uploadSpeedLimit != [torrent speedLimit:YES])
|
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
uploadSpeedLimit = INVALID;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-10-31 15:18:27 +00:00
|
|
|
if (downloadUseSpeedLimit != NSControlStateValueMixed &&
|
|
|
|
downloadUseSpeedLimit != ([torrent usesSpeedLimit:NO] ? NSControlStateValueOn : NSControlStateValueOff))
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
downloadUseSpeedLimit = NSControlStateValueMixed;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
if (downloadSpeedLimit != INVALID && downloadSpeedLimit != [torrent speedLimit:NO])
|
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
downloadSpeedLimit = INVALID;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-10-31 15:18:27 +00:00
|
|
|
if (globalUseSpeedLimit != NSControlStateValueMixed &&
|
|
|
|
globalUseSpeedLimit != (torrent.usesGlobalSpeedLimit ? NSControlStateValueOn : NSControlStateValueOff))
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
globalUseSpeedLimit = NSControlStateValueMixed;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//set upload view
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fUploadLimitCheck.state = uploadUseSpeedLimit;
|
|
|
|
self.fUploadLimitCheck.enabled = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fUploadLimitLabel.enabled = uploadUseSpeedLimit == NSControlStateValueOn;
|
|
|
|
self.fUploadLimitField.enabled = uploadUseSpeedLimit == NSControlStateValueOn;
|
2010-03-06 23:12:30 +00:00
|
|
|
if (uploadSpeedLimit != INVALID)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fUploadLimitField.intValue = uploadSpeedLimit;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fUploadLimitField.stringValue = @"";
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//set download view
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDownloadLimitCheck.state = downloadUseSpeedLimit;
|
|
|
|
self.fDownloadLimitCheck.enabled = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDownloadLimitLabel.enabled = downloadUseSpeedLimit == NSControlStateValueOn;
|
|
|
|
self.fDownloadLimitField.enabled = downloadUseSpeedLimit == NSControlStateValueOn;
|
2010-03-06 23:12:30 +00:00
|
|
|
if (downloadSpeedLimit != INVALID)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDownloadLimitField.intValue = downloadSpeedLimit;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDownloadLimitField.stringValue = @"";
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//set global check
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fGlobalLimitCheck.state = globalUseSpeedLimit;
|
|
|
|
self.fGlobalLimitCheck.enabled = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-07-24 03:19:41 +00:00
|
|
|
//get ratio and idle info
|
2022-02-22 16:04:20 +00:00
|
|
|
enumerator = [self.fTorrents objectEnumerator];
|
2010-03-06 23:12:30 +00:00
|
|
|
torrent = [enumerator nextObject]; //first torrent
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSInteger checkRatio = torrent.ratioSetting;
|
|
|
|
NSInteger checkIdle = torrent.idleSetting;
|
2021-10-31 15:18:27 +00:00
|
|
|
NSInteger removeWhenFinishSeeding = torrent.removeWhenFinishSeeding ? NSControlStateValueOn
|
|
|
|
: NSControlStateValueOff;
|
2021-08-07 07:27:56 +00:00
|
|
|
CGFloat ratioLimit = torrent.ratioLimit;
|
|
|
|
NSUInteger idleLimit = torrent.idleLimitMinutes;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
while ((torrent = [enumerator nextObject]) &&
|
|
|
|
(checkRatio != INVALID || ratioLimit != INVALID || checkIdle != INVALID || idleLimit != INVALID))
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
if (checkRatio != INVALID && checkRatio != torrent.ratioSetting)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
checkRatio = INVALID;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
if (ratioLimit != INVALID && ratioLimit != torrent.ratioLimit)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
ratioLimit = INVALID;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
if (checkIdle != INVALID && checkIdle != torrent.idleSetting)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-07-24 03:19:41 +00:00
|
|
|
checkIdle = INVALID;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
if (idleLimit != INVALID && idleLimit != torrent.idleLimitMinutes)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-07-24 03:19:41 +00:00
|
|
|
idleLimit = INVALID;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-10-31 15:18:27 +00:00
|
|
|
if (removeWhenFinishSeeding != NSControlStateValueMixed &&
|
|
|
|
removeWhenFinishSeeding != (torrent.removeWhenFinishSeeding ? NSControlStateValueOn
|
|
|
|
: NSControlStateValueOff))
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
removeWhenFinishSeeding = NSControlStateValueMixed;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//set ratio view
|
|
|
|
NSInteger index;
|
|
|
|
if (checkRatio == TR_RATIOLIMIT_SINGLE)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
index = OPTION_POPUP_LIMIT;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else if (checkRatio == TR_RATIOLIMIT_UNLIMITED)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
index = OPTION_POPUP_NO_LIMIT;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else if (checkRatio == TR_RATIOLIMIT_GLOBAL)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
index = OPTION_POPUP_GLOBAL;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
index = -1;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fRatioPopUp selectItemAtIndex:index];
|
|
|
|
self.fRatioPopUp.enabled = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioLimitField.hidden = checkRatio != TR_RATIOLIMIT_SINGLE;
|
2010-03-06 23:12:30 +00:00
|
|
|
if (ratioLimit != INVALID)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioLimitField.floatValue = ratioLimit;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioLimitField.stringValue = @"";
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioLimitGlobalLabel.hidden = checkRatio != TR_RATIOLIMIT_GLOBAL;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-07-24 03:19:41 +00:00
|
|
|
//set idle view
|
|
|
|
if (checkIdle == TR_IDLELIMIT_SINGLE)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-07-16 03:12:57 +00:00
|
|
|
index = OPTION_POPUP_LIMIT;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-07-24 03:19:41 +00:00
|
|
|
else if (checkIdle == TR_IDLELIMIT_UNLIMITED)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-07-16 03:12:57 +00:00
|
|
|
index = OPTION_POPUP_NO_LIMIT;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-07-24 03:19:41 +00:00
|
|
|
else if (checkIdle == TR_IDLELIMIT_GLOBAL)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-07-16 03:12:57 +00:00
|
|
|
index = OPTION_POPUP_GLOBAL;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-07-16 03:12:57 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-07-16 03:12:57 +00:00
|
|
|
index = -1;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fIdlePopUp selectItemAtIndex:index];
|
|
|
|
self.fIdlePopUp.enabled = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fIdleLimitField.hidden = checkIdle != TR_IDLELIMIT_SINGLE;
|
2010-07-24 03:19:41 +00:00
|
|
|
if (idleLimit != INVALID)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fIdleLimitField.integerValue = idleLimit;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-07-16 03:12:57 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fIdleLimitField.stringValue = @"";
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fIdleLimitLabel.hidden = checkIdle != TR_IDLELIMIT_SINGLE;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fIdleLimitGlobalLabel.hidden = checkIdle != TR_IDLELIMIT_GLOBAL;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-07-07 01:47:12 +00:00
|
|
|
//set remove transfer when seeding finishes
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRemoveSeedingCompleteCheck.state = removeWhenFinishSeeding;
|
|
|
|
self.fRemoveSeedingCompleteCheck.enabled = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//get priority info
|
2022-02-22 16:04:20 +00:00
|
|
|
enumerator = [self.fTorrents objectEnumerator];
|
2010-03-06 23:12:30 +00:00
|
|
|
torrent = [enumerator nextObject]; //first torrent
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
NSInteger priority = torrent.priority;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
while ((torrent = [enumerator nextObject]) && priority != INVALID)
|
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
if (priority != INVALID && priority != torrent.priority)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
priority = INVALID;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//set priority view
|
|
|
|
if (priority == TR_PRI_HIGH)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
index = OPTION_POPUP_PRIORITY_HIGH;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else if (priority == TR_PRI_NORMAL)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
index = OPTION_POPUP_PRIORITY_NORMAL;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else if (priority == TR_PRI_LOW)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
index = OPTION_POPUP_PRIORITY_LOW;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
index = -1;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fPriorityPopUp selectItemAtIndex:index];
|
|
|
|
self.fPriorityPopUp.enabled = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//get peer info
|
2022-02-22 16:04:20 +00:00
|
|
|
enumerator = [self.fTorrents objectEnumerator];
|
2010-03-06 23:12:30 +00:00
|
|
|
torrent = [enumerator nextObject]; //first torrent
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
NSInteger maxPeers = torrent.maxPeerConnect;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
while ((torrent = [enumerator nextObject]))
|
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
if (maxPeers != torrent.maxPeerConnect)
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
|
|
|
maxPeers = INVALID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
//set peer view
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fPeersConnectField.enabled = YES;
|
|
|
|
self.fPeersConnectLabel.enabled = YES;
|
2010-03-06 23:12:30 +00:00
|
|
|
if (maxPeers != INVALID)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fPeersConnectField.intValue = maxPeers;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fPeersConnectField.stringValue = @"";
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setUseSpeedLimit:(id)sender
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
BOOL const upload = sender == self.fUploadLimitCheck;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-10-31 15:18:27 +00:00
|
|
|
if (((NSButton*)sender).state == NSControlStateValueMixed)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
[sender setState:NSControlStateValueOn];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2021-10-31 15:18:27 +00:00
|
|
|
BOOL const limit = ((NSButton*)sender).state == NSControlStateValueOn;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
[torrent setUseSpeedLimit:limit upload:upload];
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
NSTextField* field = upload ? self.fUploadLimitField : self.fDownloadLimitField;
|
2021-08-07 07:27:56 +00:00
|
|
|
field.enabled = limit;
|
2010-03-06 23:12:30 +00:00
|
|
|
if (limit)
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
[field selectText:self];
|
|
|
|
[self.view.window makeKeyAndOrderFront:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
NSTextField* label = upload ? self.fUploadLimitLabel : self.fDownloadLimitLabel;
|
2021-08-07 07:27:56 +00:00
|
|
|
label.enabled = limit;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setUseGlobalSpeedLimit:(id)sender
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
if (((NSButton*)sender).state == NSControlStateValueMixed)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
[sender setState:NSControlStateValueOn];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2021-10-31 15:18:27 +00:00
|
|
|
BOOL const limit = ((NSButton*)sender).state == NSControlStateValueOn;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
torrent.usesGlobalSpeedLimit = limit;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setSpeedLimit:(id)sender
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
BOOL const upload = sender == self.fUploadLimitField;
|
2021-08-15 09:41:48 +00:00
|
|
|
NSInteger const limit = [sender intValue];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
[torrent setSpeedLimit:limit upload:upload];
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setRatioSetting:(id)sender
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
|
|
|
NSInteger setting;
|
2011-02-12 03:13:14 +00:00
|
|
|
BOOL single = NO;
|
2010-03-06 23:12:30 +00:00
|
|
|
switch ([sender indexOfSelectedItem])
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
case OPTION_POPUP_LIMIT:
|
|
|
|
setting = TR_RATIOLIMIT_SINGLE;
|
|
|
|
single = YES;
|
|
|
|
break;
|
|
|
|
case OPTION_POPUP_NO_LIMIT:
|
|
|
|
setting = TR_RATIOLIMIT_UNLIMITED;
|
|
|
|
break;
|
|
|
|
case OPTION_POPUP_GLOBAL:
|
|
|
|
setting = TR_RATIOLIMIT_GLOBAL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NSAssert1(NO, @"Unknown option selected in ratio popup: %ld", [sender indexOfSelectedItem]);
|
|
|
|
return;
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-09-24 12:56:57 +00:00
|
|
|
torrent.ratioSetting = static_cast<tr_ratiolimit>(setting);
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioLimitField.hidden = !single;
|
2010-03-06 23:12:30 +00:00
|
|
|
if (single)
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fRatioLimitField selectText:self];
|
2021-08-15 09:41:48 +00:00
|
|
|
[self.view.window makeKeyAndOrderFront:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioLimitGlobalLabel.hidden = setting != TR_RATIOLIMIT_GLOBAL;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setRatioLimit:(id)sender
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const limit = [sender floatValue];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
torrent.ratioLimit = limit;
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setIdleSetting:(id)sender
|
2010-07-16 03:12:57 +00:00
|
|
|
{
|
|
|
|
NSInteger setting;
|
2011-02-12 03:13:14 +00:00
|
|
|
BOOL single = NO;
|
2010-07-16 03:12:57 +00:00
|
|
|
switch ([sender indexOfSelectedItem])
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
case OPTION_POPUP_LIMIT:
|
|
|
|
setting = TR_IDLELIMIT_SINGLE;
|
|
|
|
single = YES;
|
|
|
|
break;
|
|
|
|
case OPTION_POPUP_NO_LIMIT:
|
|
|
|
setting = TR_IDLELIMIT_UNLIMITED;
|
|
|
|
break;
|
|
|
|
case OPTION_POPUP_GLOBAL:
|
|
|
|
setting = TR_IDLELIMIT_GLOBAL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NSAssert1(NO, @"Unknown option selected in idle popup: %ld", [sender indexOfSelectedItem]);
|
|
|
|
return;
|
2010-07-16 03:12:57 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-09-24 12:56:57 +00:00
|
|
|
torrent.idleSetting = static_cast<tr_idlelimit>(setting);
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fIdleLimitField.hidden = !single;
|
|
|
|
self.fIdleLimitLabel.hidden = !single;
|
2010-07-16 03:12:57 +00:00
|
|
|
if (single)
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fIdleLimitField selectText:self];
|
2021-08-15 09:41:48 +00:00
|
|
|
[self.view.window makeKeyAndOrderFront:self];
|
2010-07-16 03:12:57 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fIdleLimitGlobalLabel.hidden = setting != TR_IDLELIMIT_GLOBAL;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-07-16 03:12:57 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setIdleLimit:(id)sender
|
2010-07-16 03:12:57 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSUInteger const limit = [sender integerValue];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
torrent.idleLimitMinutes = limit;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-07-16 03:12:57 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (IBAction)setRemoveWhenSeedingCompletes:(id)sender
|
2012-07-07 01:47:12 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
if (((NSButton*)sender).state == NSControlStateValueMixed)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-10-31 15:18:27 +00:00
|
|
|
[sender setState:NSControlStateValueOn];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2021-10-31 15:18:27 +00:00
|
|
|
BOOL const enable = ((NSButton*)sender).state == NSControlStateValueOn;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
torrent.removeWhenFinishSeeding = enable;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2012-07-07 01:47:12 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setPriority:(id)sender
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
|
|
|
tr_priority_t priority;
|
|
|
|
switch ([sender indexOfSelectedItem])
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
case OPTION_POPUP_PRIORITY_HIGH:
|
|
|
|
priority = TR_PRI_HIGH;
|
|
|
|
break;
|
|
|
|
case OPTION_POPUP_PRIORITY_NORMAL:
|
|
|
|
priority = TR_PRI_NORMAL;
|
|
|
|
break;
|
|
|
|
case OPTION_POPUP_PRIORITY_LOW:
|
|
|
|
priority = TR_PRI_LOW;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NSAssert1(NO, @"Unknown option selected in priority popup: %ld", [sender indexOfSelectedItem]);
|
|
|
|
return;
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
torrent.priority = priority;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateUI" object:nil];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setPeersConnectLimit:(id)sender
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
|
|
|
NSInteger limit = [sender intValue];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
torrent.maxPeerConnect = limit;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptionsNotification" object:self];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (BOOL)control:(NSControl*)control textShouldBeginEditing:(NSText*)fieldEditor
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fInitialString = control.stringValue;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (BOOL)control:(NSControl*)control didFailToFormatString:(NSString*)string errorDescription:(NSString*)error
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
|
|
|
NSBeep();
|
2022-02-22 16:04:20 +00:00
|
|
|
if (self.fInitialString)
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
control.stringValue = self.fInitialString;
|
|
|
|
self.fInitialString = nil;
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
#pragma mark - Private
|
2010-03-06 23:12:30 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setupInfo
|
2010-03-09 02:26:52 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
if (self.fTorrents.count == 0)
|
|
|
|
{
|
|
|
|
self.fUploadLimitCheck.enabled = NO;
|
|
|
|
self.fUploadLimitCheck.state = NSControlStateValueOff;
|
|
|
|
self.fUploadLimitField.enabled = NO;
|
|
|
|
self.fUploadLimitLabel.enabled = NO;
|
|
|
|
self.fUploadLimitField.stringValue = @"";
|
|
|
|
|
|
|
|
self.fDownloadLimitCheck.enabled = NO;
|
|
|
|
self.fDownloadLimitCheck.state = NSControlStateValueOff;
|
|
|
|
self.fDownloadLimitField.enabled = NO;
|
|
|
|
self.fDownloadLimitLabel.enabled = NO;
|
|
|
|
self.fDownloadLimitField.stringValue = @"";
|
|
|
|
|
|
|
|
self.fGlobalLimitCheck.enabled = NO;
|
|
|
|
self.fGlobalLimitCheck.state = NSControlStateValueOff;
|
|
|
|
|
|
|
|
self.fPriorityPopUp.enabled = NO;
|
|
|
|
[self.fPriorityPopUp selectItemAtIndex:-1];
|
|
|
|
|
|
|
|
self.fRatioPopUp.enabled = NO;
|
|
|
|
[self.fRatioPopUp selectItemAtIndex:-1];
|
|
|
|
self.fRatioLimitField.hidden = YES;
|
|
|
|
self.fRatioLimitField.stringValue = @"";
|
|
|
|
self.fRatioLimitGlobalLabel.hidden = YES;
|
|
|
|
|
|
|
|
self.fIdlePopUp.enabled = NO;
|
|
|
|
[self.fIdlePopUp selectItemAtIndex:-1];
|
|
|
|
self.fIdleLimitField.hidden = YES;
|
|
|
|
self.fIdleLimitField.stringValue = @"";
|
|
|
|
self.fIdleLimitLabel.hidden = YES;
|
|
|
|
self.fIdleLimitGlobalLabel.hidden = YES;
|
|
|
|
|
|
|
|
self.fRemoveSeedingCompleteCheck.enabled = NO;
|
|
|
|
self.fRemoveSeedingCompleteCheck.state = NSControlStateValueOff;
|
|
|
|
|
|
|
|
self.fPeersConnectField.enabled = NO;
|
|
|
|
self.fPeersConnectField.stringValue = @"";
|
|
|
|
self.fPeersConnectLabel.enabled = NO;
|
2010-03-09 02:26:52 +00:00
|
|
|
}
|
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-09 02:26:52 +00:00
|
|
|
[self updateOptions];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-03-09 02:26:52 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setGlobalLabels
|
2011-02-12 03:28:36 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* global = [NSUserDefaults.standardUserDefaults boolForKey:@"RatioCheck"] ?
|
|
|
|
[NSString stringForRatio:[NSUserDefaults.standardUserDefaults floatForKey:@"RatioLimit"]] :
|
|
|
|
NSLocalizedString(@"disabled", "Info options -> global setting");
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioLimitGlobalLabel.stringValue = global;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2011-02-12 03:28:36 +00:00
|
|
|
//idle field
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* globalIdle;
|
|
|
|
if ([NSUserDefaults.standardUserDefaults boolForKey:@"IdleLimitCheck"])
|
2011-02-12 03:28:36 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSInteger const globalMin = [NSUserDefaults.standardUserDefaults integerForKey:@"IdleLimitMinutes"];
|
|
|
|
globalIdle = globalMin == 1 ?
|
|
|
|
NSLocalizedString(@"1 minute", "Info options -> global setting") :
|
|
|
|
[NSString localizedStringWithFormat:NSLocalizedString(@"%d minutes", "Info options -> global setting"), globalMin];
|
2011-02-12 03:28:36 +00:00
|
|
|
}
|
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2011-02-12 03:28:36 +00:00
|
|
|
globalIdle = NSLocalizedString(@"disabled", "Info options -> global setting");
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fIdleLimitGlobalLabel.stringValue = globalIdle;
|
2011-02-12 03:28:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)updateOptionsNotification:(NSNotification*)notification
|
2011-06-04 13:48:56 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
if (notification.object != self)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2011-06-04 13:48:56 +00:00
|
|
|
[self updateOptions];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2011-06-04 13:48:56 +00:00
|
|
|
}
|
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
@end
|