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-04-12 00:55:31 +00:00
|
|
|
|
|
|
|
#import "AddMagnetWindowController.h"
|
|
|
|
#import "Controller.h"
|
|
|
|
#import "ExpandedPathToIconTransformer.h"
|
|
|
|
#import "GroupsController.h"
|
|
|
|
#import "NSStringAdditions.h"
|
|
|
|
#import "Torrent.h"
|
|
|
|
|
|
|
|
#define POPUP_PRIORITY_HIGH 0
|
|
|
|
#define POPUP_PRIORITY_NORMAL 1
|
|
|
|
#define POPUP_PRIORITY_LOW 2
|
|
|
|
|
|
|
|
@interface AddMagnetWindowController (Private)
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)confirmAdd;
|
2010-04-12 00:55:31 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setDestinationPath:(NSString*)destination determinationType:(TorrentDeterminationType)determinationType;
|
2010-04-12 00:55:31 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setGroupsMenu;
|
|
|
|
- (void)changeGroupValue:(id)sender;
|
2010-04-12 00:55:31 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation AddMagnetWindowController
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (instancetype)initWithTorrent:(Torrent*)torrent destination:(NSString*)path controller:(Controller*)controller
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
if ((self = [super initWithWindowNibName:@"AddMagnetWindow"]))
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
|
|
|
fTorrent = torrent;
|
2021-08-07 07:27:56 +00:00
|
|
|
fDestination = path.stringByExpandingTildeInPath;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-12 00:55:31 +00:00
|
|
|
fController = controller;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
fGroupValue = torrent.groupValue;
|
2012-10-30 00:22:10 +00:00
|
|
|
fGroupDeterminationType = TorrentDeterminationAutomatic;
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)awakeFromNib
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateGroupMenu:) name:@"UpdateGroups" object:nil];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* name = fTorrent.name;
|
2021-08-07 07:27:56 +00:00
|
|
|
self.window.title = name;
|
|
|
|
fNameField.stringValue = name;
|
|
|
|
fNameField.toolTip = name;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-12 00:55:31 +00:00
|
|
|
[self setGroupsMenu];
|
2021-08-15 09:41:48 +00:00
|
|
|
[fGroupPopUp selectItemWithTag:fGroupValue];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-12 00:55:31 +00:00
|
|
|
NSInteger priorityIndex;
|
2021-08-07 07:27:56 +00:00
|
|
|
switch (fTorrent.priority)
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
case TR_PRI_HIGH:
|
|
|
|
priorityIndex = POPUP_PRIORITY_HIGH;
|
|
|
|
break;
|
|
|
|
case TR_PRI_NORMAL:
|
|
|
|
priorityIndex = POPUP_PRIORITY_NORMAL;
|
|
|
|
break;
|
|
|
|
case TR_PRI_LOW:
|
|
|
|
priorityIndex = POPUP_PRIORITY_LOW;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NSAssert1(NO, @"Unknown priority for adding torrent: %d", fTorrent.priority);
|
|
|
|
priorityIndex = POPUP_PRIORITY_NORMAL;
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
2021-08-15 09:41:48 +00:00
|
|
|
[fPriorityPopUp selectItemAtIndex:priorityIndex];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-10-31 15:18:27 +00:00
|
|
|
fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSControlStateValueOn
|
|
|
|
: NSControlStateValueOff;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-12 00:55:31 +00:00
|
|
|
if (fDestination)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
[self setDestinationPath:fDestination determinationType:TorrentDeterminationAutomatic];
|
|
|
|
}
|
2010-04-12 00:55:31 +00:00
|
|
|
else
|
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
fLocationField.stringValue = @"";
|
|
|
|
fLocationImageView.image = nil;
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
#warning when 10.7-only, switch to auto layout
|
2012-09-08 03:48:12 +00:00
|
|
|
[fMagnetLinkLabel sizeToFit];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const downloadToLabelOldWidth = fDownloadToLabel.frame.size.width;
|
2012-09-08 03:48:12 +00:00
|
|
|
[fDownloadToLabel sizeToFit];
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const changeDestOldWidth = fChangeDestinationButton.frame.size.width;
|
2012-09-08 03:48:12 +00:00
|
|
|
[fChangeDestinationButton sizeToFit];
|
2021-08-07 07:27:56 +00:00
|
|
|
NSRect changeDestFrame = fChangeDestinationButton.frame;
|
2012-09-08 03:48:12 +00:00
|
|
|
changeDestFrame.origin.x -= changeDestFrame.size.width - changeDestOldWidth;
|
2021-08-07 07:27:56 +00:00
|
|
|
fChangeDestinationButton.frame = changeDestFrame;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
NSRect downloadToBoxFrame = fDownloadToBox.frame;
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const downloadToBoxSizeDiff = (fDownloadToLabel.frame.size.width - downloadToLabelOldWidth) +
|
|
|
|
(changeDestFrame.size.width - changeDestOldWidth);
|
2012-09-08 03:48:12 +00:00
|
|
|
downloadToBoxFrame.size.width -= downloadToBoxSizeDiff;
|
2021-08-07 07:27:56 +00:00
|
|
|
downloadToBoxFrame.origin.x -= downloadToLabelOldWidth - fDownloadToLabel.frame.size.width;
|
|
|
|
fDownloadToBox.frame = downloadToBoxFrame;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
NSRect groupPopUpFrame = fGroupPopUp.frame;
|
|
|
|
NSRect priorityPopUpFrame = fPriorityPopUp.frame;
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const popUpOffset = groupPopUpFrame.origin.x - NSMaxX(fGroupLabel.frame);
|
2012-09-08 03:48:12 +00:00
|
|
|
[fGroupLabel sizeToFit];
|
|
|
|
[fPriorityLabel sizeToFit];
|
2021-08-07 07:27:56 +00:00
|
|
|
NSRect groupLabelFrame = fGroupLabel.frame;
|
|
|
|
NSRect priorityLabelFrame = fPriorityLabel.frame;
|
2012-09-08 03:48:12 +00:00
|
|
|
//first bring them both to the left edge
|
|
|
|
groupLabelFrame.origin.x = MIN(groupLabelFrame.origin.x, priorityLabelFrame.origin.x);
|
|
|
|
priorityLabelFrame.origin.x = MIN(groupLabelFrame.origin.x, priorityLabelFrame.origin.x);
|
|
|
|
//then align on the right
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const labelWidth = MAX(groupLabelFrame.size.width, priorityLabelFrame.size.width);
|
2012-09-08 03:48:12 +00:00
|
|
|
groupLabelFrame.origin.x += labelWidth - groupLabelFrame.size.width;
|
|
|
|
priorityLabelFrame.origin.x += labelWidth - priorityLabelFrame.size.width;
|
|
|
|
groupPopUpFrame.origin.x = NSMaxX(groupLabelFrame) + popUpOffset;
|
|
|
|
priorityPopUpFrame.origin.x = NSMaxX(priorityLabelFrame) + popUpOffset;
|
2021-08-07 07:27:56 +00:00
|
|
|
fGroupLabel.frame = groupLabelFrame;
|
|
|
|
fGroupPopUp.frame = groupPopUpFrame;
|
|
|
|
fPriorityLabel.frame = priorityLabelFrame;
|
|
|
|
fPriorityPopUp.frame = priorityPopUpFrame;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const minButtonWidth = 82.0;
|
|
|
|
CGFloat const oldAddButtonWidth = fAddButton.bounds.size.width;
|
|
|
|
CGFloat const oldCancelButtonWidth = fCancelButton.bounds.size.width;
|
2012-09-08 03:48:12 +00:00
|
|
|
[fAddButton sizeToFit];
|
|
|
|
[fCancelButton sizeToFit];
|
2021-08-07 07:27:56 +00:00
|
|
|
NSRect addButtonFrame = fAddButton.frame;
|
|
|
|
NSRect cancelButtonFrame = fCancelButton.frame;
|
2012-09-08 03:48:12 +00:00
|
|
|
CGFloat buttonWidth = MAX(addButtonFrame.size.width, cancelButtonFrame.size.width);
|
|
|
|
buttonWidth = MAX(buttonWidth, minButtonWidth);
|
|
|
|
addButtonFrame.size.width = buttonWidth;
|
|
|
|
cancelButtonFrame.size.width = buttonWidth;
|
2021-08-15 09:41:48 +00:00
|
|
|
CGFloat const addButtonWidthIncrease = buttonWidth - oldAddButtonWidth;
|
2012-09-08 03:48:12 +00:00
|
|
|
addButtonFrame.origin.x -= addButtonWidthIncrease;
|
|
|
|
cancelButtonFrame.origin.x -= addButtonWidthIncrease + (buttonWidth - oldCancelButtonWidth);
|
2021-08-07 07:27:56 +00:00
|
|
|
fAddButton.frame = addButtonFrame;
|
|
|
|
fCancelButton.frame = cancelButtonFrame;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-09-08 03:48:12 +00:00
|
|
|
[fStartCheck sizeToFit];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)windowDidLoad
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
|
|
|
//if there is no destination, prompt for one right away
|
|
|
|
if (!fDestination)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
[self setDestination:nil];
|
|
|
|
}
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)dealloc
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
[NSNotificationCenter.defaultCenter removeObserver:self];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (Torrent*)torrent
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
|
|
|
return fTorrent;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setDestination:(id)sender
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSOpenPanel* panel = [NSOpenPanel openPanel];
|
2010-04-12 00:55:31 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
panel.prompt = NSLocalizedString(@"Select", "Open torrent -> prompt");
|
|
|
|
panel.allowsMultipleSelection = NO;
|
|
|
|
panel.canChooseFiles = NO;
|
|
|
|
panel.canChooseDirectories = YES;
|
|
|
|
panel.canCreateDirectories = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
panel.message = [NSString stringWithFormat:NSLocalizedString(@"Select the download folder for \"%@\"", "Add -> select destination folder"),
|
|
|
|
fTorrent.name];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
|
2021-10-31 15:18:27 +00:00
|
|
|
if (result == NSModalResponseOK)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
[self setDestinationPath:panel.URLs[0].path determinationType:TorrentDeterminationUserSpecified];
|
|
|
|
}
|
2011-12-11 22:31:01 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!fDestination)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
[self performSelectorOnMainThread:@selector(cancelAdd:) withObject:nil waitUntilDone:NO];
|
|
|
|
}
|
2011-12-11 22:31:01 +00:00
|
|
|
}
|
|
|
|
}];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)add:(id)sender
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
if ([fDestination.lastPathComponent isEqualToString:fTorrent.name] &&
|
|
|
|
[NSUserDefaults.standardUserDefaults boolForKey:@"WarningFolderDataSameName"])
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSAlert* alert = [[NSAlert alloc] init];
|
|
|
|
alert.messageText = NSLocalizedString(@"The destination directory and root data directory have the same name.", "Add torrent -> same name -> title");
|
|
|
|
alert.informativeText = NSLocalizedString(
|
|
|
|
@"If you are attempting to use already existing data,"
|
|
|
|
" the root data directory should be inside the destination directory.",
|
|
|
|
"Add torrent -> same name -> message");
|
2021-10-31 15:18:27 +00:00
|
|
|
alert.alertStyle = NSAlertStyleWarning;
|
2021-08-15 09:41:48 +00:00
|
|
|
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Add torrent -> same name -> button")];
|
|
|
|
[alert addButtonWithTitle:NSLocalizedString(@"Add", "Add torrent -> same name -> button")];
|
2021-08-07 07:27:56 +00:00
|
|
|
alert.showsSuppressionButton = YES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
[alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) {
|
2021-10-31 15:18:27 +00:00
|
|
|
if (alert.suppressionButton.state == NSControlStateValueOn)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"WarningFolderDataSameName"];
|
|
|
|
}
|
2020-11-22 13:02:29 +00:00
|
|
|
|
|
|
|
if (returnCode == NSAlertSecondButtonReturn)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
[self performSelectorOnMainThread:@selector(confirmAdd) withObject:nil waitUntilDone:NO];
|
|
|
|
}
|
2020-11-22 13:02:29 +00:00
|
|
|
}];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
else
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2010-04-12 00:55:31 +00:00
|
|
|
[self confirmAdd];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)cancelAdd:(id)sender
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
[self.window performClose:sender];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//only called on cancel
|
2021-08-15 09:41:48 +00:00
|
|
|
- (BOOL)windowShouldClose:(id)window
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
[fController askOpenMagnetConfirmed:self add:NO];
|
2010-04-12 00:55:31 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)changePriority:(id)sender
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
|
|
|
tr_priority_t priority;
|
|
|
|
switch ([sender indexOfSelectedItem])
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
case POPUP_PRIORITY_HIGH:
|
|
|
|
priority = TR_PRI_HIGH;
|
|
|
|
break;
|
|
|
|
case POPUP_PRIORITY_NORMAL:
|
|
|
|
priority = TR_PRI_NORMAL;
|
|
|
|
break;
|
|
|
|
case POPUP_PRIORITY_LOW:
|
|
|
|
priority = TR_PRI_LOW;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NSAssert1(NO, @"Unknown priority tag for adding torrent: %ld", [sender tag]);
|
|
|
|
priority = TR_PRI_NORMAL;
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
2021-08-07 07:27:56 +00:00
|
|
|
fTorrent.priority = priority;
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)updateGroupMenu:(NSNotification*)notification
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
|
|
|
[self setGroupsMenu];
|
2021-08-15 09:41:48 +00:00
|
|
|
if (![fGroupPopUp selectItemWithTag:fGroupValue])
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
|
|
|
fGroupValue = -1;
|
2017-01-24 17:53:16 +00:00
|
|
|
fGroupDeterminationType = TorrentDeterminationAutomatic;
|
2021-08-15 09:41:48 +00:00
|
|
|
[fGroupPopUp selectItemWithTag:fGroupValue];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation AddMagnetWindowController (Private)
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)confirmAdd
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
[fTorrent setGroupValue:fGroupValue determinationType:fGroupDeterminationType];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-10-31 15:18:27 +00:00
|
|
|
if (fStartCheck.state == NSControlStateValueOn)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2011-08-02 12:43:26 +00:00
|
|
|
[fTorrent startTransfer];
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2010-04-12 00:55:31 +00:00
|
|
|
[self close];
|
2021-08-15 09:41:48 +00:00
|
|
|
[fController askOpenMagnetConfirmed:self add:YES];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setDestinationPath:(NSString*)destination determinationType:(TorrentDeterminationType)determinationType
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
destination = destination.stringByExpandingTildeInPath;
|
2021-08-15 09:41:48 +00:00
|
|
|
if (!fDestination || ![fDestination isEqualToString:destination])
|
2017-01-24 17:53:16 +00:00
|
|
|
{
|
2017-07-29 16:14:22 +00:00
|
|
|
fDestination = destination;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
[fTorrent changeDownloadFolderBeforeUsing:fDestination determinationType:determinationType];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-07 07:27:56 +00:00
|
|
|
fLocationField.stringValue = fDestination.stringByAbbreviatingWithTildeInPath;
|
|
|
|
fLocationField.toolTip = fDestination;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
ExpandedPathToIconTransformer* iconTransformer = [[ExpandedPathToIconTransformer alloc] init];
|
|
|
|
fLocationImageView.image = [iconTransformer transformedValue:fDestination];
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setGroupsMenu
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSMenu* groupMenu = [GroupsController.groups groupMenuWithTarget:self action:@selector(changeGroupValue:) isSmall:NO];
|
2021-08-07 07:27:56 +00:00
|
|
|
fGroupPopUp.menu = groupMenu;
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)changeGroupValue:(id)sender
|
2010-04-12 00:55:31 +00:00
|
|
|
{
|
|
|
|
NSInteger previousGroup = fGroupValue;
|
2017-01-24 17:53:16 +00:00
|
|
|
fGroupValue = [sender tag];
|
2012-10-30 00:22:10 +00:00
|
|
|
fGroupDeterminationType = TorrentDeterminationUserSpecified;
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
if ([GroupsController.groups usesCustomDownloadLocationForIndex:fGroupValue])
|
|
|
|
{
|
|
|
|
[self setDestinationPath:[GroupsController.groups customDownloadLocationForIndex:fGroupValue]
|
|
|
|
determinationType:TorrentDeterminationAutomatic];
|
|
|
|
}
|
|
|
|
else if ([fDestination isEqualToString:[GroupsController.groups customDownloadLocationForIndex:previousGroup]])
|
|
|
|
{
|
|
|
|
[self setDestinationPath:[NSUserDefaults.standardUserDefaults stringForKey:@"DownloadFolder"]
|
|
|
|
determinationType:TorrentDeterminationAutomatic];
|
|
|
|
}
|
2010-04-12 00:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|