2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2006-2022 Transmission authors and contributors.
|
|
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
#import "InfoWindowController.h"
|
2010-03-14 01:42:49 +00:00
|
|
|
#import "InfoViewController.h"
|
2010-03-06 23:12:30 +00:00
|
|
|
#import "InfoGeneralViewController.h"
|
|
|
|
#import "InfoActivityViewController.h"
|
|
|
|
#import "InfoTrackersViewController.h"
|
|
|
|
#import "InfoPeersViewController.h"
|
|
|
|
#import "InfoFileViewController.h"
|
|
|
|
#import "InfoOptionsViewController.h"
|
2021-12-05 23:42:54 +00:00
|
|
|
#import "NSImageAdditions.h"
|
2007-09-16 01:02:06 +00:00
|
|
|
#import "NSStringAdditions.h"
|
2009-09-26 04:02:39 +00:00
|
|
|
#import "Torrent.h"
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2022-10-19 19:28:21 +00:00
|
|
|
typedef NSString* TabIdentifier NS_TYPED_EXTENSIBLE_ENUM;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2022-10-19 19:28:21 +00:00
|
|
|
static TabIdentifier const TabIdentifierInfo = @"Info";
|
|
|
|
static TabIdentifier const TabIdentifierActivity = @"Activity";
|
|
|
|
static TabIdentifier const TabIdentifierTracker = @"Tracker";
|
|
|
|
static TabIdentifier const TabIdentifierPeers = @"Peers";
|
|
|
|
static TabIdentifier const TabIdentifierFiles = @"Files";
|
|
|
|
static TabIdentifier const TabIdentifierOptions = @"Options";
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2022-10-19 19:28:21 +00:00
|
|
|
static CGFloat const kTabMinHeight = 250;
|
|
|
|
|
|
|
|
static NSInteger const kInvalidTag = -99;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
typedef NS_ENUM(unsigned int, tabTag) {
|
2010-03-06 23:12:30 +00:00
|
|
|
TAB_GENERAL_TAG = 0,
|
2007-12-17 16:06:20 +00:00
|
|
|
TAB_ACTIVITY_TAG = 1,
|
2010-03-06 23:12:30 +00:00
|
|
|
TAB_TRACKERS_TAG = 2,
|
2008-02-22 01:36:30 +00:00
|
|
|
TAB_PEERS_TAG = 3,
|
2010-03-06 23:12:30 +00:00
|
|
|
TAB_FILE_TAG = 4,
|
2008-02-22 01:36:30 +00:00
|
|
|
TAB_OPTIONS_TAG = 5
|
2021-08-07 07:27:56 +00:00
|
|
|
};
|
2007-10-06 22:23:44 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
@interface InfoWindowController ()
|
|
|
|
|
2022-04-29 22:51:40 +00:00
|
|
|
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
|
2022-02-22 16:04:20 +00:00
|
|
|
|
|
|
|
@property(nonatomic) CGFloat fMinWindowWidth;
|
|
|
|
|
|
|
|
@property(nonatomic) NSViewController<InfoViewController>* fViewController;
|
|
|
|
@property(nonatomic) NSInteger fCurrentTabTag;
|
|
|
|
@property(nonatomic) IBOutlet NSSegmentedControl* fTabs;
|
|
|
|
|
|
|
|
@property(nonatomic) InfoGeneralViewController* fGeneralViewController;
|
|
|
|
@property(nonatomic) InfoActivityViewController* fActivityViewController;
|
|
|
|
@property(nonatomic) InfoTrackersViewController* fTrackersViewController;
|
|
|
|
@property(nonatomic) InfoPeersViewController* fPeersViewController;
|
|
|
|
@property(nonatomic) InfoFileViewController* fFileViewController;
|
|
|
|
@property(nonatomic) InfoOptionsViewController* fOptionsViewController;
|
|
|
|
|
|
|
|
@property(nonatomic) IBOutlet NSImageView* fImageView;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fNameField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fBasicInfoField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fNoneSelectedField;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation InfoWindowController
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (instancetype)init
|
2007-10-07 12:24:26 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
self = [super initWithWindowNibName:@"InfoWindow"];
|
2009-09-28 01:57:35 +00:00
|
|
|
return self;
|
2007-10-07 12:24:26 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)awakeFromNib
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fNoneSelectedField.stringValue = NSLocalizedString(@"No Torrents Selected", "Inspector -> selected torrents");
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
//window location and size
|
2021-08-15 09:41:48 +00:00
|
|
|
NSPanel* window = (NSPanel*)self.window;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
window.floatingPanel = NO;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const windowHeight = NSHeight(window.frame);
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fMinWindowWidth = window.minSize.width;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[window setFrameAutosaveName:@"InspectorWindow"];
|
|
|
|
[window setFrameUsingName:@"InspectorWindow"];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
NSRect windowRect = window.frame;
|
2010-03-09 02:26:52 +00:00
|
|
|
windowRect.origin.y -= windowHeight - NSHeight(windowRect);
|
2007-10-07 12:24:26 +00:00
|
|
|
windowRect.size.height = windowHeight;
|
2021-08-15 09:41:48 +00:00
|
|
|
[window setFrame:windowRect display:NO];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
window.becomesKeyOnlyIfNeeded = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-08-02 13:19:03 +00:00
|
|
|
//disable green maximise window button
|
|
|
|
//https://github.com/transmission/transmission/issues/3486
|
|
|
|
[[window standardWindowButton:NSWindowZoomButton] setEnabled:NO];
|
|
|
|
|
2022-11-14 03:39:34 +00:00
|
|
|
//set tab images and tooltips
|
|
|
|
void (^setImageAndToolTipForSegment)(NSImage*, NSString*, NSInteger) = ^(NSImage* image, NSString* toolTip, NSInteger segment) {
|
|
|
|
image.accessibilityDescription = toolTip;
|
|
|
|
[self.fTabs setImage:image forSegment:segment];
|
|
|
|
[self.fTabs.cell setToolTip:toolTip forSegment:segment];
|
|
|
|
};
|
|
|
|
setImageAndToolTipForSegment(
|
|
|
|
[NSImage systemSymbol:@"info.circle" withFallback:@"InfoGeneral"],
|
|
|
|
NSLocalizedString(@"General Info", "Inspector -> tab"),
|
|
|
|
TAB_GENERAL_TAG);
|
|
|
|
setImageAndToolTipForSegment(
|
|
|
|
[NSImage systemSymbol:@"square.grid.3x3.fill.square" withFallback:@"InfoActivity"],
|
|
|
|
NSLocalizedString(@"Activity", "Inspector -> tab"),
|
|
|
|
TAB_ACTIVITY_TAG);
|
|
|
|
setImageAndToolTipForSegment(
|
|
|
|
[NSImage systemSymbol:@"antenna.radiowaves.left.and.right" withFallback:@"InfoTracker"],
|
|
|
|
NSLocalizedString(@"Trackers", "Inspector -> tab"),
|
|
|
|
TAB_TRACKERS_TAG);
|
|
|
|
setImageAndToolTipForSegment([NSImage systemSymbol:@"person.2" withFallback:@"InfoPeers"], NSLocalizedString(@"Peers", "Inspector -> tab"), TAB_PEERS_TAG);
|
|
|
|
setImageAndToolTipForSegment([NSImage systemSymbol:@"doc.on.doc" withFallback:@"InfoFiles"], NSLocalizedString(@"Files", "Inspector -> tab"), TAB_FILE_TAG);
|
|
|
|
setImageAndToolTipForSegment(
|
|
|
|
[NSImage systemSymbol:@"gearshape" withFallback:@"InfoOptions"],
|
|
|
|
NSLocalizedString(@"Options", "Inspector -> tab"),
|
|
|
|
TAB_OPTIONS_TAG);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-10-06 22:23:44 +00:00
|
|
|
//set selected tab
|
2022-10-19 19:28:21 +00:00
|
|
|
self.fCurrentTabTag = kInvalidTag;
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* identifier = [NSUserDefaults.standardUserDefaults stringForKey:@"InspectorSelected"];
|
2008-11-02 01:07:01 +00:00
|
|
|
NSInteger tag;
|
2022-10-19 19:28:21 +00:00
|
|
|
if ([identifier isEqualToString:TabIdentifierInfo])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
tag = TAB_GENERAL_TAG;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-10-19 19:28:21 +00:00
|
|
|
else if ([identifier isEqualToString:TabIdentifierActivity])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2007-10-06 22:23:44 +00:00
|
|
|
tag = TAB_ACTIVITY_TAG;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-10-19 19:28:21 +00:00
|
|
|
else if ([identifier isEqualToString:TabIdentifierTracker])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
tag = TAB_TRACKERS_TAG;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-10-19 19:28:21 +00:00
|
|
|
else if ([identifier isEqualToString:TabIdentifierPeers])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2007-10-06 22:23:44 +00:00
|
|
|
tag = TAB_PEERS_TAG;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-10-19 19:28:21 +00:00
|
|
|
else if ([identifier isEqualToString:TabIdentifierFiles])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-03-06 23:12:30 +00:00
|
|
|
tag = TAB_FILE_TAG;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-10-19 19:28:21 +00:00
|
|
|
else if ([identifier isEqualToString:TabIdentifierOptions])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2007-10-06 22:23:44 +00:00
|
|
|
tag = TAB_OPTIONS_TAG;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2007-10-06 22:23:44 +00:00
|
|
|
else //safety
|
|
|
|
{
|
2022-10-19 19:28:21 +00:00
|
|
|
[NSUserDefaults.standardUserDefaults setObject:TabIdentifierInfo forKey:@"InspectorSelected"];
|
2010-03-06 23:12:30 +00:00
|
|
|
tag = TAB_GENERAL_TAG;
|
2007-10-06 22:23:44 +00:00
|
|
|
}
|
2021-12-05 23:42:54 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fTabs.selectedSegment = tag;
|
2021-08-15 09:41:48 +00:00
|
|
|
[self setTab:nil];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
//set blank inspector
|
2021-08-15 09:41:48 +00:00
|
|
|
[self setInfoForTorrents:@[]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
//allow for update notifications
|
2021-08-15 09:41:48 +00:00
|
|
|
NSNotificationCenter* nc = NSNotificationCenter.defaultCenter;
|
|
|
|
[nc addObserver:self selector:@selector(resetInfoForTorrent:) name:@"ResetInspector" object:nil];
|
|
|
|
[nc addObserver:self selector:@selector(updateInfoStats) name:@"UpdateStats" object:nil];
|
|
|
|
[nc addObserver:self selector:@selector(updateOptions) name:@"UpdateOptions" object:nil];
|
2022-07-17 23:04:32 +00:00
|
|
|
|
|
|
|
//add a custom window resize notification heer so we can disable it temporarily in settab:
|
|
|
|
[nc addObserver:self selector:@selector(windowWasResized:) name:NSWindowDidResizeNotification object:self.window];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)dealloc
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter removeObserver:self];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
if ([_fViewController respondsToSelector:@selector(saveViewSize)])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
[_fViewController saveViewSize];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2022-07-17 23:04:32 +00:00
|
|
|
- (void)windowWasResized:(NSNotification*)notification
|
|
|
|
{
|
|
|
|
if (self.fViewController == self.fOptionsViewController)
|
|
|
|
{
|
2022-12-16 18:27:37 +00:00
|
|
|
[self.fOptionsViewController checkWindowSize];
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
else if (self.fViewController == self.fActivityViewController)
|
|
|
|
{
|
2022-12-16 18:27:37 +00:00
|
|
|
[self.fActivityViewController checkWindowSize];
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-29 22:51:40 +00:00
|
|
|
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-12-21 20:21:16 +00:00
|
|
|
if ([self.fTorrents isEqualToArray:torrents])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2008-02-27 13:59:26 +00:00
|
|
|
return;
|
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.fTorrents = torrents;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-11-27 16:55:36 +00:00
|
|
|
[self resetInfo];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSRect)windowWillUseStandardFrame:(NSWindow*)window defaultFrame:(NSRect)defaultFrame
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
NSRect windowRect = window.frame;
|
|
|
|
windowRect.size.width = window.minSize.width;
|
2007-10-07 15:55:27 +00:00
|
|
|
return windowRect;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)windowWillClose:(NSNotification*)notification
|
2009-10-11 23:50:13 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
if (self.fCurrentTabTag == TAB_FILE_TAG && ([QLPreviewPanel sharedPreviewPanelExists] && [QLPreviewPanel sharedPreviewPanel].visible))
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2011-10-06 00:30:40 +00:00
|
|
|
[[QLPreviewPanel sharedPreviewPanel] reloadData];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2009-10-11 23:50:13 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setTab:(id)sender
|
2007-10-07 15:55:27 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
NSInteger const oldTabTag = self.fCurrentTabTag;
|
2022-04-03 13:41:09 +00:00
|
|
|
self.fCurrentTabTag = self.fTabs.selectedSegment;
|
2022-02-22 16:04:20 +00:00
|
|
|
if (self.fCurrentTabTag == oldTabTag)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2008-02-27 02:06:46 +00:00
|
|
|
return;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-07-17 23:04:32 +00:00
|
|
|
//remove window resize notification
|
|
|
|
[NSNotificationCenter.defaultCenter removeObserver:self name:NSWindowDidResizeNotification object:self.window];
|
|
|
|
|
2008-02-27 02:06:46 +00:00
|
|
|
//take care of old view
|
2008-11-02 01:07:01 +00:00
|
|
|
CGFloat oldHeight = 0;
|
2022-10-19 19:28:21 +00:00
|
|
|
if (oldTabTag != kInvalidTag)
|
2008-02-27 02:06:46 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
if ([self.fViewController respondsToSelector:@selector(saveViewSize)])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fViewController saveViewSize];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
if ([self.fViewController respondsToSelector:@selector(clearView)])
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fViewController clearView];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
NSView* oldView = self.fViewController.view;
|
2021-08-07 07:27:56 +00:00
|
|
|
oldHeight = NSHeight(oldView.frame);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-02-27 13:52:43 +00:00
|
|
|
//remove old view
|
2008-02-27 02:06:46 +00:00
|
|
|
[oldView removeFromSuperview];
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2008-02-27 13:52:43 +00:00
|
|
|
//set new tab item
|
2022-10-19 19:28:21 +00:00
|
|
|
TabIdentifier identifier;
|
2022-02-22 16:04:20 +00:00
|
|
|
switch (self.fCurrentTabTag)
|
2007-10-07 15:55:27 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
case TAB_GENERAL_TAG:
|
2022-02-22 16:04:20 +00:00
|
|
|
if (!self.fGeneralViewController)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fGeneralViewController = [[InfoGeneralViewController alloc] init];
|
|
|
|
[self.fGeneralViewController setInfoForTorrents:self.fTorrents];
|
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.fViewController = self.fGeneralViewController;
|
2022-10-19 19:28:21 +00:00
|
|
|
identifier = TabIdentifierInfo;
|
2021-08-15 09:41:48 +00:00
|
|
|
break;
|
|
|
|
case TAB_ACTIVITY_TAG:
|
2022-02-22 16:04:20 +00:00
|
|
|
if (!self.fActivityViewController)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fActivityViewController = [[InfoActivityViewController alloc] init];
|
|
|
|
[self.fActivityViewController setInfoForTorrents:self.fTorrents];
|
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.fViewController = self.fActivityViewController;
|
2022-10-19 19:28:21 +00:00
|
|
|
identifier = TabIdentifierActivity;
|
2021-08-15 09:41:48 +00:00
|
|
|
break;
|
|
|
|
case TAB_TRACKERS_TAG:
|
2022-02-22 16:04:20 +00:00
|
|
|
if (!self.fTrackersViewController)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fTrackersViewController = [[InfoTrackersViewController alloc] init];
|
|
|
|
[self.fTrackersViewController setInfoForTorrents:self.fTorrents];
|
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.fViewController = self.fTrackersViewController;
|
2022-10-19 19:28:21 +00:00
|
|
|
identifier = TabIdentifierTracker;
|
2021-08-15 09:41:48 +00:00
|
|
|
break;
|
|
|
|
case TAB_PEERS_TAG:
|
2022-02-22 16:04:20 +00:00
|
|
|
if (!self.fPeersViewController)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fPeersViewController = [[InfoPeersViewController alloc] init];
|
|
|
|
[self.fPeersViewController setInfoForTorrents:self.fTorrents];
|
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.fViewController = self.fPeersViewController;
|
2022-10-19 19:28:21 +00:00
|
|
|
identifier = TabIdentifierPeers;
|
2021-08-15 09:41:48 +00:00
|
|
|
break;
|
|
|
|
case TAB_FILE_TAG:
|
2022-02-22 16:04:20 +00:00
|
|
|
if (!self.fFileViewController)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fFileViewController = [[InfoFileViewController alloc] init];
|
|
|
|
[self.fFileViewController setInfoForTorrents:self.fTorrents];
|
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.fViewController = self.fFileViewController;
|
2022-10-19 19:28:21 +00:00
|
|
|
identifier = TabIdentifierFiles;
|
2021-08-15 09:41:48 +00:00
|
|
|
break;
|
|
|
|
case TAB_OPTIONS_TAG:
|
2022-02-22 16:04:20 +00:00
|
|
|
if (!self.fOptionsViewController)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fOptionsViewController = [[InfoOptionsViewController alloc] init];
|
|
|
|
[self.fOptionsViewController setInfoForTorrents:self.fTorrents];
|
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.fViewController = self.fOptionsViewController;
|
2022-10-19 19:28:21 +00:00
|
|
|
identifier = TabIdentifierOptions;
|
2021-08-15 09:41:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
2022-02-22 16:04:20 +00:00
|
|
|
NSAssert1(NO, @"Unknown info tab selected: %ld", self.fCurrentTabTag);
|
2021-08-15 09:41:48 +00:00
|
|
|
return;
|
2007-10-07 15:55:27 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSUserDefaults.standardUserDefaults setObject:identifier forKey:@"InspectorSelected"];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSWindow* window = self.window;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
window.title = [NSString
|
2022-02-22 16:04:20 +00:00
|
|
|
stringWithFormat:@"%@ - %@", self.fViewController.title, NSLocalizedString(@"Torrent Inspector", "Inspector -> title")];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
NSView* view = self.fViewController.view;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fViewController updateInfo];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
NSRect windowRect = window.frame, viewRect = view.frame;
|
2022-07-17 23:04:32 +00:00
|
|
|
CGFloat minWindowWidth = MAX(self.fMinWindowWidth, view.fittingSize.width);
|
|
|
|
|
|
|
|
//special case for Activity and Options views
|
|
|
|
if (self.fViewController == self.fActivityViewController)
|
|
|
|
{
|
2022-12-16 18:27:37 +00:00
|
|
|
[self.fActivityViewController setOldHeight:oldHeight];
|
|
|
|
[self.fActivityViewController checkLayout];
|
|
|
|
|
2022-07-17 23:04:32 +00:00
|
|
|
minWindowWidth = MAX(self.fMinWindowWidth, self.fActivityViewController.fTransferView.frame.size.width);
|
|
|
|
viewRect = [self.fActivityViewController viewRect];
|
|
|
|
}
|
|
|
|
else if (self.fViewController == self.fOptionsViewController)
|
|
|
|
{
|
2022-12-16 18:27:37 +00:00
|
|
|
[self.fOptionsViewController setOldHeight:oldHeight];
|
|
|
|
[self.fOptionsViewController checkLayout];
|
|
|
|
|
2022-07-17 23:04:32 +00:00
|
|
|
minWindowWidth = MAX(self.fMinWindowWidth, self.fOptionsViewController.fPriorityView.frame.size.width);
|
|
|
|
viewRect = [self.fOptionsViewController viewRect];
|
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const difference = NSHeight(viewRect) - oldHeight;
|
2007-10-06 22:23:44 +00:00
|
|
|
windowRect.origin.y -= difference;
|
|
|
|
windowRect.size.height += difference;
|
2016-02-27 20:29:57 +00:00
|
|
|
windowRect.size.width = MAX(NSWidth(windowRect), minWindowWidth);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
if ([self.fViewController respondsToSelector:@selector(saveViewSize)]) //a little bit hacky, but avoids requiring an extra method
|
2007-10-06 22:23:44 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
if (window.screen)
|
2011-12-25 22:05:18 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const screenHeight = NSHeight(window.screen.visibleFrame);
|
2011-12-25 22:15:13 +00:00
|
|
|
if (NSHeight(windowRect) > screenHeight)
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const difference = screenHeight - NSHeight(windowRect);
|
2011-12-25 22:15:13 +00:00
|
|
|
windowRect.origin.y -= difference;
|
|
|
|
windowRect.size.height += difference;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2011-12-25 22:15:13 +00:00
|
|
|
viewRect.size.height += difference;
|
|
|
|
}
|
2011-12-25 22:05:18 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-10-19 19:28:21 +00:00
|
|
|
window.minSize = NSMakeSize(minWindowWidth, NSHeight(windowRect) - NSHeight(viewRect) + kTabMinHeight);
|
2021-08-07 07:27:56 +00:00
|
|
|
window.maxSize = NSMakeSize(FLT_MAX, FLT_MAX);
|
2007-10-06 22:23:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
window.minSize = NSMakeSize(minWindowWidth, NSHeight(windowRect));
|
|
|
|
window.maxSize = NSMakeSize(FLT_MAX, NSHeight(windowRect));
|
2007-10-06 22:23:44 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-03-14 02:59:37 +00:00
|
|
|
viewRect.size.width = NSWidth(windowRect);
|
2021-08-07 07:27:56 +00:00
|
|
|
view.frame = viewRect;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-07-17 23:04:32 +00:00
|
|
|
if (self.fViewController == self.fActivityViewController)
|
|
|
|
{
|
|
|
|
self.fActivityViewController.view.hidden = YES;
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[self.fActivityViewController updateWindowLayout];
|
|
|
|
self.fActivityViewController.view.hidden = NO;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (self.fViewController == self.fOptionsViewController)
|
|
|
|
{
|
|
|
|
self.fOptionsViewController.view.hidden = YES;
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[self.fOptionsViewController updateWindowLayout];
|
|
|
|
self.fOptionsViewController.view.hidden = NO;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-10-19 19:28:21 +00:00
|
|
|
[window setFrame:windowRect display:YES animate:oldTabTag != kInvalidTag];
|
2022-07-17 23:04:32 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[window.contentView addSubview:view];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[window.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[view]-0-|" options:0 metrics:nil
|
|
|
|
views:@{ @"view" : view }]];
|
|
|
|
[window.contentView
|
|
|
|
addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[tabs]-0-[view]-0-|" options:0 metrics:nil
|
2022-02-22 16:04:20 +00:00
|
|
|
views:@{ @"tabs" : self.fTabs, @"view" : view }]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
if ((self.fCurrentTabTag == TAB_FILE_TAG || oldTabTag == TAB_FILE_TAG) &&
|
2021-08-15 09:41:48 +00:00
|
|
|
([QLPreviewPanel sharedPreviewPanelExists] && [QLPreviewPanel sharedPreviewPanel].visible))
|
|
|
|
{
|
2011-10-06 00:30:40 +00:00
|
|
|
[[QLPreviewPanel sharedPreviewPanel] reloadData];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2022-07-17 23:04:32 +00:00
|
|
|
|
|
|
|
//add window resize notification
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(windowWasResized:)
|
|
|
|
name:NSWindowDidResizeNotification
|
|
|
|
object:self.window];
|
|
|
|
});
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setNextTab
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
NSInteger tag = self.fTabs.selectedSegment + 1;
|
|
|
|
if (tag >= self.fTabs.segmentCount)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2007-10-06 22:23:44 +00:00
|
|
|
tag = 0;
|
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.fTabs.selectedSegment = tag;
|
2021-08-15 09:41:48 +00:00
|
|
|
[self setTab:nil];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setPreviousTab
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
NSInteger tag = self.fTabs.selectedSegment - 1;
|
2007-10-06 22:23:44 +00:00
|
|
|
if (tag < 0)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
tag = self.fTabs.segmentCount - 1;
|
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.fTabs.selectedSegment = tag;
|
2021-08-15 09:41:48 +00:00
|
|
|
[self setTab:nil];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)swipeWithEvent:(NSEvent*)event
|
2010-10-15 23:39:14 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
if (event.deltaX < 0.0)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-10-15 23:39:14 +00:00
|
|
|
[self setNextTab];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2021-08-07 07:27:56 +00:00
|
|
|
else if (event.deltaX > 0.0)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-10-15 23:39:14 +00:00
|
|
|
[self setPreviousTab];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-10-15 23:39:14 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)updateInfoStats
|
2010-03-14 01:42:49 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fViewController updateInfo];
|
2010-03-14 01:42:49 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)updateOptions
|
2008-06-02 17:26:02 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fOptionsViewController updateOptions];
|
2008-06-02 17:26:02 +00:00
|
|
|
}
|
|
|
|
|
2022-04-29 22:51:40 +00:00
|
|
|
- (NSArray<NSURL*>*)quickLookURLs
|
2009-09-04 04:10:46 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
return self.fFileViewController.quickLookURLs;
|
2009-09-04 04:10:46 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (BOOL)canQuickLook
|
2009-09-04 04:10:46 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
if (self.fCurrentTabTag != TAB_FILE_TAG || !self.window.visible)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2009-10-11 23:16:46 +00:00
|
|
|
return NO;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
return self.fFileViewController.canQuickLook;
|
2009-09-04 04:10:46 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSRect)quickLookSourceFrameForPreviewItem:(id<QLPreviewItem>)item
|
2009-09-04 04:10:46 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
return [self.fFileViewController quickLookSourceFrameForPreviewItem:item];
|
2007-12-22 05:21:25 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
#pragma mark - Private
|
2007-10-07 15:55:27 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)resetInfo
|
2009-11-27 16:55:36 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
NSUInteger const numberSelected = self.fTorrents.count;
|
2009-11-27 16:55:36 +00:00
|
|
|
if (numberSelected != 1)
|
|
|
|
{
|
|
|
|
if (numberSelected > 0)
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fImageView.image = [NSImage imageNamed:NSImageNameMultipleDocuments];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-05-14 05:31:24 +00:00
|
|
|
self.fNameField.stringValue = [NSString
|
2022-11-14 18:30:03 +00:00
|
|
|
localizedStringWithFormat:NSLocalizedString(@"%lu Torrents Selected", "Inspector -> selected torrents"), numberSelected];
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fNameField.hidden = NO;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-11-27 16:55:36 +00:00
|
|
|
uint64_t size = 0;
|
2009-11-27 20:47:03 +00:00
|
|
|
NSUInteger fileCount = 0, magnetCount = 0;
|
2022-02-22 16:04:20 +00:00
|
|
|
for (Torrent* torrent in self.fTorrents)
|
2009-11-27 16:55:36 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
size += torrent.size;
|
|
|
|
fileCount += torrent.fileCount;
|
|
|
|
if (torrent.magnet)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2009-11-27 20:47:03 +00:00
|
|
|
++magnetCount;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2009-11-27 16:55:36 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSMutableArray* fileStrings = [NSMutableArray arrayWithCapacity:2];
|
2009-11-27 20:47:03 +00:00
|
|
|
if (fileCount > 0)
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* fileString;
|
2009-11-27 20:47:03 +00:00
|
|
|
if (fileCount == 1)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2009-11-27 20:47:03 +00:00
|
|
|
fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents");
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2009-11-27 20:47:03 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-11-14 18:30:03 +00:00
|
|
|
fileString = [NSString
|
|
|
|
localizedStringWithFormat:NSLocalizedString(@"%lu files", "Inspector -> selected torrents"), fileCount];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
|
|
|
[fileStrings addObject:fileString];
|
2009-11-27 20:47:03 +00:00
|
|
|
}
|
|
|
|
if (magnetCount > 0)
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* magnetString;
|
2009-11-27 20:47:03 +00:00
|
|
|
if (magnetCount == 1)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2009-11-27 20:47:03 +00:00
|
|
|
magnetString = NSLocalizedString(@"1 magnetized transfer", "Inspector -> selected torrents");
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2009-11-27 20:47:03 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-05-14 05:31:24 +00:00
|
|
|
magnetString = [NSString
|
2022-11-14 18:30:03 +00:00
|
|
|
localizedStringWithFormat:NSLocalizedString(@"%lu magnetized transfers", "Inspector -> selected torrents"), magnetCount];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
|
|
|
[fileStrings addObject:magnetString];
|
2009-11-27 20:47:03 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* fileString = [fileStrings componentsJoinedByString:@" + "];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-11-27 20:47:03 +00:00
|
|
|
if (magnetCount < numberSelected)
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fBasicInfoField.stringValue = [NSString
|
2021-08-15 09:41:48 +00:00
|
|
|
stringWithFormat:@"%@, %@",
|
|
|
|
fileString,
|
|
|
|
[NSString stringWithFormat:NSLocalizedString(@"%@ total", "Inspector -> selected torrents"),
|
|
|
|
[NSString stringForFileSize:size]]];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSByteCountFormatter* formatter = [[NSByteCountFormatter alloc] init];
|
2021-08-07 07:27:56 +00:00
|
|
|
formatter.allowedUnits = NSByteCountFormatterUseBytes;
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fBasicInfoField.toolTip = [formatter stringFromByteCount:size];
|
2009-11-27 20:47:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fBasicInfoField.stringValue = fileString;
|
|
|
|
self.fBasicInfoField.toolTip = nil;
|
2009-11-27 20:47:03 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fBasicInfoField.hidden = NO;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fNoneSelectedField.hidden = YES;
|
2009-11-27 16:55:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fImageView.image = [NSImage imageNamed:NSImageNameApplicationIcon];
|
|
|
|
self.fNoneSelectedField.hidden = NO;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fNameField.hidden = YES;
|
|
|
|
self.fBasicInfoField.hidden = YES;
|
2009-11-27 16:55:36 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fNameField.toolTip = nil;
|
2009-11-27 16:55:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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.fImageView.image = torrent.icon;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* name = torrent.name;
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fNameField.stringValue = name;
|
|
|
|
self.fNameField.toolTip = name;
|
|
|
|
self.fNameField.hidden = NO;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
if (!torrent.magnet)
|
2009-11-27 16:55:36 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* basicString = [NSString stringForFileSize:torrent.size];
|
2021-08-07 07:27:56 +00:00
|
|
|
if (torrent.folder)
|
2009-11-27 20:47:03 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* fileString;
|
|
|
|
NSUInteger const fileCount = torrent.fileCount;
|
2009-11-27 20:47:03 +00:00
|
|
|
if (fileCount == 1)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2009-11-27 20:47:03 +00:00
|
|
|
fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents");
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2009-11-27 20:47:03 +00:00
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-11-14 18:30:03 +00:00
|
|
|
fileString = [NSString
|
|
|
|
localizedStringWithFormat:NSLocalizedString(@"%lu files", "Inspector -> selected torrents"), fileCount];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
|
|
|
basicString = [NSString stringWithFormat:@"%@, %@", fileString, basicString];
|
2009-11-27 20:47:03 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fBasicInfoField.stringValue = basicString;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSByteCountFormatter* formatter = [[NSByteCountFormatter alloc] init];
|
2021-08-07 07:27:56 +00:00
|
|
|
formatter.allowedUnits = NSByteCountFormatterUseBytes;
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fBasicInfoField.toolTip = [formatter stringFromByteCount:torrent.size];
|
2009-11-27 20:47:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fBasicInfoField.stringValue = NSLocalizedString(@"Magnetized transfer", "Inspector -> selected torrents");
|
|
|
|
self.fBasicInfoField.toolTip = nil;
|
2009-11-27 16:55:36 +00:00
|
|
|
}
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fBasicInfoField.hidden = NO;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fNoneSelectedField.hidden = YES;
|
2010-02-06 15:42:18 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fGeneralViewController setInfoForTorrents:self.fTorrents];
|
|
|
|
[self.fActivityViewController setInfoForTorrents:self.fTorrents];
|
|
|
|
[self.fTrackersViewController setInfoForTorrents:self.fTorrents];
|
|
|
|
[self.fPeersViewController setInfoForTorrents:self.fTorrents];
|
|
|
|
[self.fFileViewController setInfoForTorrents:self.fTorrents];
|
|
|
|
[self.fOptionsViewController setInfoForTorrents:self.fTorrents];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.fViewController updateInfo];
|
2009-11-27 16:55:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)resetInfoForTorrent:(NSNotification*)notification
|
2009-12-05 16:10:59 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
Torrent* torrent = notification.userInfo[@"Torrent"];
|
2022-02-22 16:04:20 +00:00
|
|
|
if (self.fTorrents && (!torrent || [self.fTorrents containsObject:torrent]))
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2009-12-05 16:10:59 +00:00
|
|
|
[self resetInfo];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2009-12-05 16:10:59 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 12:24:26 +00:00
|
|
|
@end
|