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
|
|
|
|
2018-09-30 10:37:30 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
|
|
|
#include <libtransmission/utils.h> //tr_getRatio()
|
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
#import "InfoActivityViewController.h"
|
|
|
|
#import "NSStringAdditions.h"
|
|
|
|
#import "PiecesView.h"
|
|
|
|
#import "Torrent.h"
|
2010-04-23 16:59:14 +00:00
|
|
|
|
2022-10-19 19:28:21 +00:00
|
|
|
typedef NS_ENUM(NSUInteger, PiecesControlSegment) {
|
|
|
|
PiecesControlSegmentProgress = 0,
|
|
|
|
PiecesControlSegmentAvailable = 1,
|
|
|
|
};
|
2010-03-06 23:12:30 +00:00
|
|
|
|
2022-10-19 19:28:21 +00:00
|
|
|
static CGFloat const kStackViewInset = 12.0;
|
|
|
|
static CGFloat const kStackViewHorizontalSpacing = 20.0;
|
|
|
|
static CGFloat const kStackViewVerticalSpacing = 8.0;
|
2022-07-17 23:04:32 +00:00
|
|
|
|
2022-01-24 01:32:45 +00:00
|
|
|
@interface InfoActivityViewController ()
|
2010-03-09 02:26:52 +00:00
|
|
|
|
2022-04-29 22:51:40 +00:00
|
|
|
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
|
2022-02-22 16:04:20 +00:00
|
|
|
|
|
|
|
@property(nonatomic) BOOL fSet;
|
|
|
|
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fDateAddedField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fDateCompletedField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fDateActivityField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fStateField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fProgressField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fHaveField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fDownloadedTotalField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fUploadedTotalField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fFailedHashField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fRatioField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fDownloadTimeField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fSeedTimeField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextView* fErrorMessageView;
|
|
|
|
|
|
|
|
@property(nonatomic) IBOutlet PiecesView* fPiecesView;
|
|
|
|
@property(nonatomic) IBOutlet NSSegmentedControl* fPiecesControl;
|
|
|
|
|
2022-07-17 23:04:32 +00:00
|
|
|
@property(nonatomic) IBOutlet NSStackView* fActivityStackView;
|
|
|
|
@property(nonatomic) IBOutlet NSView* fDatesView;
|
2022-12-21 20:21:16 +00:00
|
|
|
@property(nonatomic, readonly) CGFloat fHeightChange;
|
2022-12-16 18:27:37 +00:00
|
|
|
@property(nonatomic, readwrite) CGFloat fCurrentHeight;
|
|
|
|
@property(nonatomic, readonly) CGFloat fHorizLayoutHeight;
|
|
|
|
@property(nonatomic, readonly) CGFloat fHorizLayoutWidth;
|
|
|
|
@property(nonatomic, readonly) CGFloat fVertLayoutHeight;
|
2022-07-17 23:04:32 +00:00
|
|
|
|
2010-03-09 02:26:52 +00:00
|
|
|
@end
|
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
@implementation InfoActivityViewController
|
|
|
|
|
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:@"InfoActivityView" bundle:nil]))
|
2010-03-14 03:09:12 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
self.title = NSLocalizedString(@"Activity", "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
|
2010-04-06 01:41:16 +00:00
|
|
|
{
|
2022-12-16 18:27:37 +00:00
|
|
|
[self checkWindowSize];
|
2010-04-06 01:41:16 +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
|
|
|
}
|
|
|
|
|
2022-12-16 18:27:37 +00:00
|
|
|
- (CGFloat)fHorizLayoutHeight
|
2022-07-17 23:04:32 +00:00
|
|
|
{
|
2022-10-19 19:28:21 +00:00
|
|
|
return NSHeight(self.fTransferView.frame) + 2 * kStackViewInset;
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 18:27:37 +00:00
|
|
|
- (CGFloat)fHorizLayoutWidth
|
2022-07-17 23:04:32 +00:00
|
|
|
{
|
2022-10-19 19:28:21 +00:00
|
|
|
return NSWidth(self.fTransferView.frame) + NSWidth(self.fDatesView.frame) + (2 * kStackViewInset) + kStackViewHorizontalSpacing;
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 18:27:37 +00:00
|
|
|
- (CGFloat)fVertLayoutHeight
|
2022-07-17 23:04:32 +00:00
|
|
|
{
|
2022-10-19 19:28:21 +00:00
|
|
|
return NSHeight(self.fTransferView.frame) + NSHeight(self.fDatesView.frame) + (2 * kStackViewInset) + kStackViewVerticalSpacing;
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 18:27:37 +00:00
|
|
|
- (CGFloat)fHeightChange
|
|
|
|
{
|
|
|
|
return self.oldHeight - self.fCurrentHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)viewRect
|
2022-07-17 23:04:32 +00:00
|
|
|
{
|
2022-12-16 18:27:37 +00:00
|
|
|
NSRect viewRect = self.view.frame;
|
2022-12-21 20:21:16 +00:00
|
|
|
|
|
|
|
CGFloat difference = self.fHeightChange;
|
2022-12-24 17:54:37 +00:00
|
|
|
viewRect.size.height -= difference;
|
2022-12-16 18:27:37 +00:00
|
|
|
|
|
|
|
return viewRect;
|
|
|
|
}
|
2022-07-17 23:04:32 +00:00
|
|
|
|
2022-12-16 18:27:37 +00:00
|
|
|
- (void)checkLayout
|
|
|
|
{
|
|
|
|
if (NSWidth(self.view.window.frame) >= self.fHorizLayoutWidth + 1)
|
2022-07-17 23:04:32 +00:00
|
|
|
{
|
|
|
|
self.fActivityStackView.orientation = NSUserInterfaceLayoutOrientationHorizontal;
|
|
|
|
|
|
|
|
//add some padding between views in horizontal layout
|
2022-10-19 19:28:21 +00:00
|
|
|
self.fActivityStackView.spacing = kStackViewHorizontalSpacing;
|
2022-12-16 18:27:37 +00:00
|
|
|
self.fCurrentHeight = self.fHorizLayoutHeight;
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.fActivityStackView.orientation = NSUserInterfaceLayoutOrientationVertical;
|
2022-10-19 19:28:21 +00:00
|
|
|
self.fActivityStackView.spacing = kStackViewVerticalSpacing;
|
2022-12-16 18:27:37 +00:00
|
|
|
self.fCurrentHeight = self.fVertLayoutHeight;
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 18:27:37 +00:00
|
|
|
- (void)checkWindowSize
|
2022-07-17 23:04:32 +00:00
|
|
|
{
|
2022-12-16 18:27:37 +00:00
|
|
|
self.oldHeight = self.fCurrentHeight;
|
2022-07-17 23:04:32 +00:00
|
|
|
|
2022-12-24 17:54:37 +00:00
|
|
|
[self updateWindowLayout];
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateWindowLayout
|
|
|
|
{
|
2022-12-24 17:54:37 +00:00
|
|
|
[self checkLayout];
|
2022-12-16 18:27:37 +00:00
|
|
|
|
2022-12-24 17:54:37 +00:00
|
|
|
CGFloat difference = self.fHeightChange;
|
2022-12-16 18:27:37 +00:00
|
|
|
|
2022-12-24 17:54:37 +00:00
|
|
|
NSRect windowRect = self.view.window.frame;
|
|
|
|
windowRect.origin.y += difference;
|
|
|
|
windowRect.size.height -= difference;
|
2022-07-17 23:04:32 +00:00
|
|
|
|
2022-12-24 17:54:37 +00:00
|
|
|
self.view.window.minSize = NSMakeSize(self.view.window.minSize.width, NSHeight(windowRect));
|
|
|
|
self.view.window.maxSize = NSMakeSize(FLT_MAX, NSHeight(windowRect));
|
2022-07-17 23:04:32 +00:00
|
|
|
|
2022-12-24 17:54:37 +00:00
|
|
|
self.view.frame = [self viewRect];
|
|
|
|
[self.view.window setFrame:windowRect display:YES animate:YES];
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
|
2022-04-29 22:51:40 +00:00
|
|
|
- (void)setInfoForTorrents:(NSArray<Torrent*>*)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-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)updateInfo
|
2010-03-06 23:12:30 +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
|
|
|
NSInteger const numberSelected = self.fTorrents.count;
|
2010-03-06 23:12:30 +00:00
|
|
|
if (numberSelected == 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
|
|
|
|
2022-12-16 18:27:37 +00:00
|
|
|
uint64_t have = 0;
|
|
|
|
uint64_t haveVerified = 0;
|
|
|
|
uint64_t downloadedTotal = 0;
|
|
|
|
uint64_t uploadedTotal = 0;
|
|
|
|
uint64_t failedHash = 0;
|
2021-08-15 09:41:48 +00:00
|
|
|
NSDate* lastActivity = nil;
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
have += torrent.haveTotal;
|
|
|
|
haveVerified += torrent.haveVerified;
|
|
|
|
downloadedTotal += torrent.downloadedTotal;
|
|
|
|
uploadedTotal += torrent.uploadedTotal;
|
|
|
|
failedHash += torrent.failedHash;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSDate* nextLastActivity;
|
2021-08-07 07:27:56 +00:00
|
|
|
if ((nextLastActivity = torrent.dateActivity))
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
lastActivity = lastActivity ? [lastActivity laterDate:nextLastActivity] : nextLastActivity;
|
|
|
|
}
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
if (have == 0)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fHaveField.stringValue = [NSString stringForFileSize:0];
|
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
|
|
|
NSString* verifiedString = [NSString stringWithFormat:NSLocalizedString(@"%@ verified", "Inspector -> Activity tab -> have"),
|
|
|
|
[NSString stringForFileSize:haveVerified]];
|
2010-03-06 23:12:30 +00:00
|
|
|
if (have == haveVerified)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fHaveField.stringValue = verifiedString;
|
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.fHaveField.stringValue = [NSString stringWithFormat:@"%@ (%@)", [NSString stringForFileSize:have], verifiedString];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
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.fDownloadedTotalField.stringValue = [NSString stringForFileSize:downloadedTotal];
|
|
|
|
self.fUploadedTotalField.stringValue = [NSString stringForFileSize:uploadedTotal];
|
|
|
|
self.fFailedHashField.stringValue = [NSString stringForFileSize:failedHash];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDateActivityField.objectValue = lastActivity;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-06 23:12:30 +00:00
|
|
|
if (numberSelected == 1)
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
Torrent* torrent = self.fTorrents[0];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fStateField.stringValue = torrent.stateString;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* progressString = [NSString percentString:torrent.progress longDecimals:YES];
|
2021-08-07 07:27:56 +00:00
|
|
|
if (torrent.folder)
|
2010-06-18 03:21:29 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* progressSelectedString = [NSString
|
|
|
|
stringWithFormat:NSLocalizedString(@"%@ selected", "Inspector -> Activity tab -> progress"),
|
|
|
|
[NSString percentString:torrent.progressDone longDecimals:YES]];
|
|
|
|
progressString = [progressString stringByAppendingFormat:@" (%@)", progressSelectedString];
|
2010-06-18 03:21:29 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fProgressField.stringValue = progressString;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioField.stringValue = [NSString stringForRatio:torrent.ratio];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* errorMessage = torrent.errorMessage;
|
2022-02-22 16:04:20 +00:00
|
|
|
if (![errorMessage isEqualToString:self.fErrorMessageView.string])
|
|
|
|
self.fErrorMessageView.string = errorMessage;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDateCompletedField.objectValue = torrent.dateCompleted;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-04-17 10:59:59 +00:00
|
|
|
//uses a relative date, so can't be set once
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDateAddedField.objectValue = torrent.dateAdded;
|
2021-08-15 09:41:48 +00:00
|
|
|
|
|
|
|
static NSDateComponentsFormatter* timeFormatter;
|
2020-12-23 03:00:06 +00:00
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
timeFormatter = [NSDateComponentsFormatter new];
|
|
|
|
timeFormatter.unitsStyle = NSDateComponentsFormatterUnitsStyleShort;
|
|
|
|
timeFormatter.allowedUnits = NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
|
|
|
|
timeFormatter.zeroFormattingBehavior = NSDateComponentsFormatterZeroFormattingBehaviorDropLeading;
|
|
|
|
});
|
2021-08-15 09:41:48 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDownloadTimeField.stringValue = [timeFormatter stringFromTimeInterval:torrent.secondsDownloading];
|
|
|
|
self.fSeedTimeField.stringValue = [timeFormatter stringFromTimeInterval:torrent.secondsSeeding];
|
2021-08-15 09:41:48 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fPiecesView updateView];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
else if (numberSelected > 1)
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fRatioField.stringValue = [NSString stringForRatio:tr_getRatio(uploadedTotal, downloadedTotal)];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setPiecesView:(id)sender
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2022-10-19 19:28:21 +00:00
|
|
|
BOOL const availability = [sender selectedSegment] == PiecesControlSegmentAvailable;
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSUserDefaults.standardUserDefaults setBool:availability forKey:@"PiecesViewShowAvailability"];
|
2013-03-12 03:33:54 +00:00
|
|
|
[self updatePiecesView:nil];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)updatePiecesView:(id)sender
|
2013-03-12 03:08:59 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
BOOL const piecesAvailableSegment = [NSUserDefaults.standardUserDefaults boolForKey:@"PiecesViewShowAvailability"];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-10-19 19:28:21 +00:00
|
|
|
[self.fPiecesControl setSelected:piecesAvailableSegment forSegment:PiecesControlSegmentAvailable];
|
|
|
|
[self.fPiecesControl setSelected:!piecesAvailableSegment forSegment:PiecesControlSegmentProgress];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fPiecesView updateView];
|
2013-03-12 03:08:59 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)clearView
|
2010-03-06 23:12:30 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fPiecesView clearView];
|
2010-03-06 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
#pragma mark - Private
|
|
|
|
|
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
|
|
|
NSUInteger const count = self.fTorrents.count;
|
2010-03-09 02:26:52 +00:00
|
|
|
if (count != 1)
|
|
|
|
{
|
|
|
|
if (count == 0)
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fHaveField.stringValue = @"";
|
|
|
|
self.fDownloadedTotalField.stringValue = @"";
|
|
|
|
self.fUploadedTotalField.stringValue = @"";
|
|
|
|
self.fFailedHashField.stringValue = @"";
|
|
|
|
self.fDateActivityField.objectValue = @""; //using [field setStringValue: @""] causes "December 31, 1969 7:00 PM" to be displayed, at least on 10.7.3
|
|
|
|
self.fRatioField.stringValue = @"";
|
2010-03-09 02:26:52 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fStateField.stringValue = @"";
|
|
|
|
self.fProgressField.stringValue = @"";
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fErrorMessageView.string = @"";
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-04-17 03:11:34 +00:00
|
|
|
//using [field setStringValue: @""] causes "December 31, 1969 7:00 PM" to be displayed, at least on 10.7.3
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDateAddedField.objectValue = @"";
|
|
|
|
self.fDateCompletedField.objectValue = @"";
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fDownloadTimeField.stringValue = @"";
|
|
|
|
self.fSeedTimeField.stringValue = @"";
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-10-19 19:28:21 +00:00
|
|
|
[self.fPiecesControl setSelected:NO forSegment:PiecesControlSegmentAvailable];
|
|
|
|
[self.fPiecesControl setSelected:NO forSegment:PiecesControlSegmentProgress];
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fPiecesControl.enabled = NO;
|
|
|
|
self.fPiecesView.torrent = nil;
|
2010-03-09 02:26:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
Torrent* torrent = self.fTorrents[0];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
BOOL const piecesAvailableSegment = [NSUserDefaults.standardUserDefaults boolForKey:@"PiecesViewShowAvailability"];
|
2022-10-19 19:28:21 +00:00
|
|
|
[self.fPiecesControl setSelected:piecesAvailableSegment forSegment:PiecesControlSegmentAvailable];
|
|
|
|
[self.fPiecesControl setSelected:!piecesAvailableSegment forSegment:PiecesControlSegmentProgress];
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fPiecesControl.enabled = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fPiecesView.torrent = torrent;
|
2010-03-09 02:26:52 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fSet = YES;
|
2010-03-09 02:26:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|