[macos] Replace Deprecated constants. (#2038)

* Replace Deprecated constants pt.1

- `NSOnState` -> `NSControlStateValueOn`
- `NSOffState` -> `NSControlStateValueOff`
- `MSMixedState` -> `NSControlStateValueMixed`

* Replace Deprecated constants pt.2

- `NS(\w+)AlertStyle` -> `NSAlertStyle$1`

* Replace Deprecated constants pt.3

- `NSFileHandlingPanel(\w+)Button` -> `NSModalResponse$1`

* Replace Deprecated constants pt.4

- `NSMouse(Entered|Exited)Mask` -> `NSEventMaskMouse$1`
- `NS(Left|Right)Mouse(Down|Up|Dragged)Mask` -> `NSEventMask$1Mouse$2`
- `NSMouse(Entered|Exited)` -> `NSEventTypeMouse$1`
- `NS(Left|Right)Mouse(Up|Down)` -> `NSEventType$1Mouse$2`

* Replace Deprecated constants pt.5

- `NSComposite(\w+)` -> `NSCompositingOperation$1`

* Replace Deprecated constants pt.6

- `NSAlternateKeyMask` -> `NSEventModifierFlagOption`
- `NSCommandKeyMask` -> `NSEventModifierFlagCommand`

* Replace Deprecated constants pt.7

- `NS(\w+)TextAlignment` -> `NSTextAlignment$1`
- `NSBackgroundStyleDark` -> `NSBackgroundStyleEmphasized`

* Replace Deprecated constants pt.8

- `NSTexturedRoundedBezelStyle` -> `NSBezelStyleTexturedRounded`
- `NSBorderlessWindowMask` -> `NSWindowStyleMaskBorderless`
- `NS(OK|Cancel)Button` -> `NSModalResponse$1`
This commit is contained in:
Dzmitry Neviadomski 2021-10-31 18:18:27 +03:00 committed by GitHub
parent 8cac7d6f94
commit b8c01a581e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 207 additions and 182 deletions

View File

@ -89,7 +89,8 @@
}
[fPriorityPopUp selectItemAtIndex:priorityIndex];
fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSOnState : NSOffState;
fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSControlStateValueOn
: NSControlStateValueOff;
if (fDestination)
{
@ -193,7 +194,7 @@
fTorrent.name];
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
[self setDestinationPath:panel.URLs[0].path determinationType:TorrentDeterminationUserSpecified];
}
@ -218,13 +219,13 @@
@"If you are attempting to use already existing data,"
" the root data directory should be inside the destination directory.",
"Add torrent -> same name -> message");
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Add torrent -> same name -> button")];
[alert addButtonWithTitle:NSLocalizedString(@"Add", "Add torrent -> same name -> button")];
alert.showsSuppressionButton = YES;
[alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) {
if (alert.suppressionButton.state == NSOnState)
if (alert.suppressionButton.state == NSControlStateValueOn)
{
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"WarningFolderDataSameName"];
}
@ -293,7 +294,7 @@
{
[fTorrent setGroupValue:fGroupValue determinationType:fGroupDeterminationType];
if (fStartCheck.state == NSOnState)
if (fStartCheck.state == NSControlStateValueOn)
{
[fTorrent startTransfer];
}

View File

@ -132,9 +132,10 @@
}
[fPriorityPopUp selectItemAtIndex:priorityIndex];
fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSOnState : NSOffState;
fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSControlStateValueOn
: NSControlStateValueOff;
fDeleteCheck.state = fDeleteTorrentEnableInitially ? NSOnState : NSOffState;
fDeleteCheck.state = fDeleteTorrentEnableInitially ? NSControlStateValueOn : NSControlStateValueOff;
fDeleteCheck.enabled = fCanToggleDelete;
if (fDestination)
@ -188,7 +189,7 @@
fTorrent.name];
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
fLockDestination = YES;
[self setDestinationPath:panel.URLs[0].path determinationType:TorrentDeterminationUserSpecified];
@ -214,13 +215,13 @@
@"If you are attempting to use already existing data,"
" the root data directory should be inside the destination directory.",
"Add torrent -> same name -> message");
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Add torrent -> same name -> button")];
[alert addButtonWithTitle:NSLocalizedString(@"Add", "Add torrent -> same name -> button")];
alert.showsSuppressionButton = YES;
[alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) {
if (alert.suppressionButton.state == NSOnState)
if (alert.suppressionButton.state == NSControlStateValueOn)
{
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"WarningFolderDataSameName"];
}
@ -305,7 +306,7 @@
//keep synced with identical code in InfoFileViewController.m
NSInteger const filesCheckState = [fTorrent
checkForFiles:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, fTorrent.fileCount)]];
fCheckAllButton.enabled = filesCheckState != NSOnState; //if anything is unchecked
fCheckAllButton.enabled = filesCheckState != NSControlStateValueOn; //if anything is unchecked
fUncheckAllButton.enabled = !fTorrent.allDownloaded; //if there are any checked files that aren't finished
//status field
@ -379,12 +380,12 @@
fTimer = nil;
[fTorrent setGroupValue:fGroupValue determinationType:fGroupValueDetermination];
if (fTorrentFile && fCanToggleDelete && fDeleteCheck.state == NSOnState)
if (fTorrentFile && fCanToggleDelete && fDeleteCheck.state == NSControlStateValueOn)
{
[Torrent trashFile:fTorrentFile error:nil];
}
if (fStartCheck.state == NSOnState)
if (fStartCheck.state == NSControlStateValueOn)
{
[fTorrent startTransfer];
}

View File

@ -66,7 +66,7 @@
- (void)drawRect:(NSRect)rect
{
[NSApp.applicationIconImage drawInRect:rect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
[NSApp.applicationIconImage drawInRect:rect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0];
if (fQuitting)
{
@ -118,7 +118,7 @@
badgeRect.origin.x = 0.0;
badgeRect.origin.y = height;
[badge drawInRect:badgeRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
[badge drawInRect:badgeRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0];
//make sure text fits on the badge
CGFloat fontSize = 26.0;

View File

@ -115,7 +115,7 @@ BlocklistDownloaderViewController* fBLViewController = nil;
NSAlert* alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:NSLocalizedString(@"OK", "Blocklist -> button")];
alert.messageText = NSLocalizedString(@"Download of the blocklist failed.", "Blocklist -> message");
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
alert.informativeText = error;

View File

@ -298,7 +298,7 @@ static void removeKeRangerRansomware()
@"There is already a copy of Transmission running. "
"This copy cannot be opened until that instance is quit.",
"Transmission already running alert -> message");
alert.alertStyle = NSCriticalAlertStyle;
alert.alertStyle = NSAlertStyleCritical;
[alert runModal];
@ -328,7 +328,7 @@ static void removeKeRangerRansomware()
" When you run a torrent, its data will be made available to others by means of upload."
" You and you alone are fully responsible for exercising proper judgement and abiding by your local laws.",
"Legal alert -> message");
alert.alertStyle = NSInformationalAlertStyle;
alert.alertStyle = NSAlertStyleInformational;
if ([alert runModal] == NSAlertSecondButtonReturn)
{
@ -785,7 +785,7 @@ static void removeKeRangerRansomware()
NSLocalizedString(@"Donate or not, there will be no difference to your torrenting experience.", "Donation beg -> message")];
alert.informativeText = donateMessage;
alert.alertStyle = NSInformationalAlertStyle;
alert.alertStyle = NSAlertStyleInformational;
[alert addButtonWithTitle:[NSLocalizedString(@"Donate", "Donation beg -> button") stringByAppendingEllipsis]];
NSButton* noDonateButton = [alert addButtonWithTitle:NSLocalizedString(@"Nope", "Donation beg -> button")];
@ -807,7 +807,7 @@ static void removeKeRangerRansomware()
if (allowNeverAgain)
{
[fDefaults setBool:(alert.suppressionButton.state != NSOnState) forKey:@"WarningDonate"];
[fDefaults setBool:(alert.suppressionButton.state != NSControlStateValueOn) forKey:@"WarningDonate"];
}
}
}
@ -1331,7 +1331,7 @@ static void removeKeRangerRansomware()
panel.allowedFileTypes = @[ @"org.bittorrent.torrent", @"torrent" ];
[panel beginSheetModalForWindow:fWindow completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
NSMutableArray* filenames = [NSMutableArray arrayWithCapacity:panel.URLs.count];
for (NSURL* url in panel.URLs)
@ -1359,11 +1359,11 @@ static void removeKeRangerRansomware()
stringWithFormat:NSLocalizedString(@"\"%@\" is not a valid torrent file.", "Open invalid alert -> title"), filename];
alert.informativeText = NSLocalizedString(@"The torrent file cannot be opened because it contains invalid data.", "Open invalid alert -> message");
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert addButtonWithTitle:NSLocalizedString(@"OK", "Open invalid alert -> button")];
[alert runModal];
if (alert.suppressionButton.state == NSOnState)
if (alert.suppressionButton.state == NSControlStateValueOn)
{
[fDefaults setBool:NO forKey:@"WarningInvalidOpen"];
}
@ -1383,11 +1383,11 @@ static void removeKeRangerRansomware()
" The transfer will not occur.",
"Magnet link failed -> message"),
address];
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert addButtonWithTitle:NSLocalizedString(@"OK", "Magnet link failed -> button")];
[alert runModal];
if (alert.suppressionButton.state == NSOnState)
if (alert.suppressionButton.state == NSControlStateValueOn)
{
[fDefaults setBool:NO forKey:@"WarningInvalidOpen"];
}
@ -1407,7 +1407,7 @@ static void removeKeRangerRansomware()
@"The transfer cannot be added because it is a duplicate of an already existing transfer.",
"Open duplicate alert -> message");
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert addButtonWithTitle:NSLocalizedString(@"OK", "Open duplicate alert -> button")];
alert.showsSuppressionButton = YES;
@ -1440,7 +1440,7 @@ static void removeKeRangerRansomware()
@"The magnet link \"%@\" cannot be added because it is a duplicate of an already existing transfer.",
"Open duplicate magnet alert -> message"),
address];
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert addButtonWithTitle:NSLocalizedString(@"OK", "Open duplicate magnet alert -> button")];
alert.showsSuppressionButton = YES;
@ -1881,7 +1881,7 @@ static void removeKeRangerRansomware()
NSAlert* alert = [[NSAlert alloc] init];
alert.messageText = message;
alert.informativeText = info;
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert addButtonWithTitle:NSLocalizedString(@"Remove", "Remove completed confirm panel -> button")];
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Remove completed confirm panel -> button")];
alert.showsSuppressionButton = YES;
@ -1929,7 +1929,7 @@ static void removeKeRangerRansomware()
}
[panel beginSheetModalForWindow:fWindow completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
for (Torrent* torrent in torrents)
{
@ -1963,7 +1963,7 @@ static void removeKeRangerRansomware()
[panel beginSheetModalForWindow:fWindow completionHandler:^(NSInteger result) {
//copy torrent to new location with name of data file
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
[torrent copyTorrentFileTo:panel.URL.path];
}
@ -1984,7 +1984,7 @@ static void removeKeRangerRansomware()
alert.informativeText = [NSString
stringWithFormat:NSLocalizedString(@"The torrent file (%@) cannot be found.", "Torrent file copy alert -> message"),
torrent.torrentLocation];
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert runModal];
}
@ -4210,7 +4210,7 @@ static void removeKeRangerRansomware()
ButtonToolbarItem* item = [[klass alloc] initWithItemIdentifier:ident];
NSButton* button = [[NSButton alloc] init];
button.bezelStyle = NSTexturedRoundedBezelStyle;
button.bezelStyle = NSBezelStyleTexturedRounded;
button.stringValue = @"";
item.view = button;
@ -4521,7 +4521,7 @@ static void removeKeRangerRansomware()
NSButton* itemButton = (NSButton*)item.view;
itemButton.target = self;
itemButton.action = @selector(showToolbarShare:);
[itemButton sendActionOn:NSLeftMouseDownMask];
[itemButton sendActionOn:NSEventMaskLeftMouseDown];
return item;
}
@ -4695,7 +4695,7 @@ static void removeKeRangerRansomware()
if (action == @selector(toggleSpeedLimit:))
{
menuItem.state = [fDefaults boolForKey:@"SpeedLimit"] ? NSOnState : NSOffState;
menuItem.state = [fDefaults boolForKey:@"SpeedLimit"] ? NSControlStateValueOn : NSControlStateValueOff;
return YES;
}
@ -4743,7 +4743,7 @@ static void removeKeRangerRansomware()
sortType = SORT_ORDER;
}
menuItem.state = [sortType isEqualToString:[fDefaults stringForKey:@"Sort"]] ? NSOnState : NSOffState;
menuItem.state = [sortType isEqualToString:[fDefaults stringForKey:@"Sort"]] ? NSControlStateValueOn : NSControlStateValueOff;
return fWindow.visible;
}
@ -4761,25 +4761,26 @@ static void removeKeRangerRansomware()
}
}
menuItem.state = checked ? NSOnState : NSOffState;
menuItem.state = checked ? NSControlStateValueOn : NSControlStateValueOff;
return canUseTable && fTableView.numberOfSelectedRows > 0;
}
if (action == @selector(toggleSmallView:))
{
menuItem.state = [fDefaults boolForKey:@"SmallView"] ? NSOnState : NSOffState;
menuItem.state = [fDefaults boolForKey:@"SmallView"] ? NSControlStateValueOn : NSControlStateValueOff;
return fWindow.visible;
}
if (action == @selector(togglePiecesBar:))
{
menuItem.state = [fDefaults boolForKey:@"PiecesBar"] ? NSOnState : NSOffState;
menuItem.state = [fDefaults boolForKey:@"PiecesBar"] ? NSControlStateValueOn : NSControlStateValueOff;
return fWindow.visible;
}
if (action == @selector(toggleAvailabilityBar:))
{
menuItem.state = [fDefaults boolForKey:@"DisplayProgressBarAvailable"] ? NSOnState : NSOffState;
menuItem.state = [fDefaults boolForKey:@"DisplayProgressBarAvailable"] ? NSControlStateValueOn
: NSControlStateValueOff;
return fWindow.visible;
}
@ -5072,14 +5073,15 @@ static void removeKeRangerRansomware()
if (action == @selector(setSortReverse:))
{
BOOL const isReverse = menuItem.tag == SORT_DESC_TAG;
menuItem.state = (isReverse == [fDefaults boolForKey:@"SortReverse"]) ? NSOnState : NSOffState;
menuItem.state = (isReverse == [fDefaults boolForKey:@"SortReverse"]) ? NSControlStateValueOn
: NSControlStateValueOff;
return ![[fDefaults stringForKey:@"Sort"] isEqualToString:SORT_ORDER];
}
//enable group sort item
if (action == @selector(setSortByGroup:))
{
menuItem.state = [fDefaults boolForKey:@"SortByGroup"] ? NSOnState : NSOffState;
menuItem.state = [fDefaults boolForKey:@"SortByGroup"] ? NSControlStateValueOn : NSControlStateValueOff;
return YES;
}

View File

@ -88,7 +88,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
alert.informativeText = NSLocalizedString(
@"There must be at least one file in a folder to create a torrent file.",
"Create torrent -> no files -> warning");
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert runModal];
@ -100,7 +100,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
[alert addButtonWithTitle:NSLocalizedString(@"OK", "Create torrent -> zero size -> button")];
alert.messageText = NSLocalizedString(@"The total file size is zero bytes.", "Create torrent -> zero size -> title");
alert.informativeText = NSLocalizedString(@"A torrent file cannot be created for files with no size.", "Create torrent -> zero size -> warning");
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert runModal];
@ -203,7 +203,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
//set previously saved values
if ([fDefaults objectForKey:@"CreatorPrivate"])
{
fPrivateCheck.state = [fDefaults boolForKey:@"CreatorPrivate"] ? NSOnState : NSOffState;
fPrivateCheck.state = [fDefaults boolForKey:@"CreatorPrivate"] ? NSControlStateValueOn : NSControlStateValueOff;
}
if ([fDefaults objectForKey:@"CreatorSource"])
@ -211,7 +211,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
fSource.stringValue = [fDefaults stringForKey:@"CreatorSource"];
}
fOpenCheck.state = [fDefaults boolForKey:@"CreatorOpen"] ? NSOnState : NSOffState;
fOpenCheck.state = [fDefaults boolForKey:@"CreatorOpen"] ? NSControlStateValueOn : NSControlStateValueOff;
}
- (void)dealloc
@ -278,7 +278,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
panel.nameFieldStringValue = fLocation.lastPathComponent;
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
fLocation = panel.URL;
[self updateLocationField];
@ -294,7 +294,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
[self.window endEditingFor:fTrackerTable];
}
BOOL const isPrivate = fPrivateCheck.state == NSOnState;
BOOL const isPrivate = fPrivateCheck.state == NSControlStateValueOn;
if (fTrackers.count == 0 && [fDefaults boolForKey:isPrivate ? @"WarningCreatorPrivateBlankAddress" : @"WarningCreatorBlankAddress"])
{
NSAlert* alert = [[NSAlert alloc] init];
@ -317,10 +317,10 @@ NSMutableSet* creatorWindowControllerSet = nil;
alert.showsSuppressionButton = YES;
[alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) {
if (alert.suppressionButton.state == NSOnState)
if (alert.suppressionButton.state == NSControlStateValueOn)
{
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"WarningCreatorBlankAddress"]; //set regardless of private/public
if (fPrivateCheck.state == NSOnState)
if (fPrivateCheck.state == NSControlStateValueOn)
{
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"WarningCreatorPrivateBlankAddress"];
}
@ -536,7 +536,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
"Create this directory or choose a different one to create the torrent file.",
"Create torrent -> directory doesn't exist warning -> warning"),
fLocation.URLByDeletingLastPathComponent.path];
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert beginSheetModalForWindow:self.window completionHandler:nil];
return;
@ -559,7 +559,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
"Create torrent -> file already exists warning -> warning"),
pathComponents[count - 1],
pathComponents[count - 2]];
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert beginSheetModalForWindow:self.window completionHandler:nil];
return;
@ -576,10 +576,10 @@ NSMutableSet* creatorWindowControllerSet = nil;
//store values
[fDefaults setObject:fTrackers forKey:@"CreatorTrackers"];
[fDefaults setBool:fPrivateCheck.state == NSOnState forKey:@"CreatorPrivate"];
[fDefaults setBool:fPrivateCheck.state == NSControlStateValueOn forKey:@"CreatorPrivate"];
[fDefaults setObject: [fSource stringValue] forKey: @"CreatorSource"];
[fDefaults setBool:fOpenCheck.state == NSOnState forKey:@"CreatorOpen"];
fOpenWhenCreated = fOpenCheck.state == NSOnState; //need this since the check box might not exist, and value in prefs might have changed from another creator window
[fDefaults setBool:fOpenCheck.state == NSControlStateValueOn forKey:@"CreatorOpen"];
fOpenWhenCreated = fOpenCheck.state == NSControlStateValueOn; //need this since the check box might not exist, and value in prefs might have changed from another creator window
[fDefaults setURL:fLocation.URLByDeletingLastPathComponent forKey:@"CreatorLocationURL"];
self.window.restorable = NO;
@ -591,7 +591,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
trackerInfo,
fTrackers.count,
fCommentView.string.UTF8String,
fPrivateCheck.state == NSOnState,
fPrivateCheck.state == NSControlStateValueOn,
fSource.stringValue.UTF8String);
tr_free(trackerInfo);
@ -627,7 +627,7 @@ NSMutableSet* creatorWindowControllerSet = nil;
[alert addButtonWithTitle:NSLocalizedString(@"OK", "Create torrent -> failed -> button")];
alert.messageText = [NSString stringWithFormat:NSLocalizedString(@"Creation of \"%@\" failed.", "Create torrent -> failed -> title"),
fLocation.lastPathComponent];
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
if (fInfo->result == TR_MAKEMETA_IO_READ)
{

View File

@ -72,7 +72,7 @@
//place icon
[icon drawInRect:NSMakeRect(PADDING, (NSHeight(badgeRect) - ICON_WIDTH) * 0.5, ICON_WIDTH, ICON_WIDTH) fromRect:NSZeroRect
operation:NSCompositeSourceOver
operation:NSCompositingOperationSourceOver
fraction:1.0];
//place main text
@ -104,7 +104,7 @@
NSSize const imageSize = fBadge.size;
[fBadge drawAtPoint:NSMakePoint((NSWidth(frame) - imageSize.width) * 0.5, (NSHeight(frame) - imageSize.height) * 0.5)
fromRect:NSZeroRect
operation:NSCompositeSourceOver
operation:NSCompositingOperationSourceOver
fraction:1.0];
}
}

View File

@ -34,7 +34,10 @@
- (instancetype)initWithLib:(tr_session*)lib forWindow:(NSWindow*)window
{
if ((self = ([super initWithContentRect:window.frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])))
if ((self = ([super initWithContentRect:window.frame
styleMask:NSWindowStyleMaskBorderless
backing:NSBackingStoreBuffered
defer:NO])))
{
fLib = lib;

View File

@ -101,17 +101,17 @@
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
{
//icon
[self.image drawInRect:[self imageRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0
[self.image drawInRect:[self imageRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0
respectFlipped:YES
hints:nil];
NSColor *titleColor, *statusColor;
FileListNode* node = self.objectValue;
if (self.backgroundStyle == NSBackgroundStyleDark)
if (self.backgroundStyle == NSBackgroundStyleEmphasized)
{
titleColor = statusColor = NSColor.whiteColor;
}
else if ([node.torrent checkForFiles:node.indexes] == NSOffState)
else if ([node.torrent checkForFiles:node.indexes] == NSControlStateValueOff)
{
titleColor = statusColor = NSColor.disabledControlTextColor;
}

View File

@ -287,7 +287,7 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
if ([identifier isEqualToString:@"Check"])
{
NSIndexSet* indexSet;
if (NSEvent.modifierFlags & NSAlternateKeyMask)
if (NSEvent.modifierFlags & NSEventModifierFlagOption)
{
indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, fTorrent.fileCount)];
}
@ -296,7 +296,9 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
indexSet = ((FileListNode*)item).indexes;
}
[fTorrent setFileCheckState:[object intValue] != NSOffState ? NSOnState : NSOffState forIndexes:indexSet];
[fTorrent setFileCheckState:[object intValue] != NSControlStateValueOff ? NSControlStateValueOn
: NSControlStateValueOff
forIndexes:indexSet];
fOutline.needsDisplay = YES;
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateUI" object:nil];
@ -330,11 +332,11 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
{
switch (cell.state)
{
case NSOffState:
case NSControlStateValueOff:
return NSLocalizedString(@"Don't Download", "files tab -> tooltip");
case NSOnState:
case NSControlStateValueOn:
return NSLocalizedString(@"Download", "files tab -> tooltip");
case NSMixedState:
case NSControlStateValueMixed:
return NSLocalizedString(@"Download Some", "files tab -> tooltip");
}
}
@ -378,7 +380,7 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
- (void)setCheck:(id)sender
{
NSInteger state = [sender tag] == FILE_UNCHECK_TAG ? NSOffState : NSOnState;
NSInteger state = [sender tag] == FILE_UNCHECK_TAG ? NSControlStateValueOff : NSControlStateValueOn;
NSIndexSet* indexSet = fOutline.selectedRowIndexes;
NSMutableIndexSet* itemIndexes = [NSMutableIndexSet indexSet];
@ -402,11 +404,11 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
[itemIndexes addIndexes:item.indexes];
}
[fTorrent setFileCheckState:NSOnState forIndexes:itemIndexes];
[fTorrent setFileCheckState:NSControlStateValueOn forIndexes:itemIndexes];
NSMutableIndexSet* remainingItemIndexes = [NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(0, fTorrent.fileCount)];
[remainingItemIndexes removeIndexes:itemIndexes];
[fTorrent setFileCheckState:NSOffState forIndexes:remainingItemIndexes];
[fTorrent setFileCheckState:NSControlStateValueOff forIndexes:remainingItemIndexes];
fOutline.needsDisplay = YES;
}
@ -414,14 +416,14 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
- (void)checkAll
{
NSIndexSet* indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, fTorrent.fileCount)];
[fTorrent setFileCheckState:NSOnState forIndexes:indexSet];
[fTorrent setFileCheckState:NSControlStateValueOn forIndexes:indexSet];
fOutline.needsDisplay = YES;
}
- (void)uncheckAll
{
NSIndexSet* indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, fTorrent.fileCount)];
[fTorrent setFileCheckState:NSOffState forIndexes:indexSet];
[fTorrent setFileCheckState:NSControlStateValueOff forIndexes:indexSet];
fOutline.needsDisplay = YES;
}
@ -538,7 +540,7 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
[itemIndexes addIndexes:node.indexes];
}
NSInteger state = (menuItem.tag == FILE_CHECK_TAG) ? NSOnState : NSOffState;
NSInteger state = (menuItem.tag == FILE_CHECK_TAG) ? NSControlStateValueOn : NSControlStateValueOff;
return [fTorrent checkForFiles:itemIndexes] != state && [fTorrent canChangeDownloadCheckForFiles:itemIndexes];
}
@ -564,7 +566,7 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
{
if (fOutline.numberOfSelectedRows == 0)
{
menuItem.state = NSOffState;
menuItem.state = NSControlStateValueOff;
return NO;
}
@ -602,7 +604,7 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
}
}
menuItem.state = current ? NSOnState : NSOffState;
menuItem.state = current ? NSControlStateValueOn : NSControlStateValueOff;
return canChange;
}

View File

@ -35,7 +35,7 @@
if ((self = [super init]))
{
self.trackingMode = NSSegmentSwitchTrackingSelectAny;
self.controlSize = NSMiniControlSize;
self.controlSize = NSControlSizeMini;
self.segmentCount = 3;
for (NSInteger i = 0; i < self.segmentCount; i++)
@ -131,7 +131,7 @@
if (count == 0)
{
//if ([self backgroundStyle] != NSBackgroundStyleDark)
//if ([self backgroundStyle] != NSBackgroundStyleEmphasized)
{
NSImage* image = [[NSImage imageNamed:@"PriorityNormalTemplate"] imageWithColor:NSColor.lightGrayColor];
[images addObject:image];
@ -140,7 +140,7 @@
}
else
{
NSColor* priorityColor = self.backgroundStyle == NSBackgroundStyleDark ? NSColor.whiteColor : NSColor.darkGrayColor;
NSColor* priorityColor = self.backgroundStyle == NSBackgroundStyleEmphasized ? NSColor.whiteColor : NSColor.darkGrayColor;
totalWidth = 0.0;
if ([priorities containsObject:@(TR_PRI_LOW)])
@ -179,7 +179,7 @@
imageSize.width,
imageSize.height);
[image drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES
[image drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES
hints:nil];
currentWidth += imageSize.width - IMAGE_OVERLAP;

View File

@ -64,7 +64,7 @@ typedef void (^CompletionBlock)(BOOL);
FileRenameSheetController* renamer = (__bridge_transfer FileRenameSheetController*)(contextInfo);
NSParameterAssert([renamer isKindOfClass:[FileRenameSheetController class]]);
renamer.completionHandler(returnCode == NSOKButton);
renamer.completionHandler(returnCode == NSModalResponseOK);
[sheet orderOut:self];
}
@ -112,7 +112,7 @@ typedef void (^CompletionBlock)(BOOL);
void (^completionHandler)(BOOL) = ^(BOOL didRename) {
if (didRename)
{
[NSApp endSheet:self.window returnCode:NSOKButton];
[NSApp endSheet:self.window returnCode:NSModalResponseOK];
}
else
{
@ -133,7 +133,7 @@ typedef void (^CompletionBlock)(BOOL);
- (IBAction)cancelRename:(id)sender
{
[NSApp endSheet:self.window returnCode:NSCancelButton];
[NSApp endSheet:self.window returnCode:NSModalResponseCancel];
}
- (void)controlTextDidChange:(NSNotification*)notification

View File

@ -97,7 +97,7 @@
}
currentFilterButton = fNoFilterButton;
}
currentFilterButton.state = NSOnState;
currentFilterButton.state = NSControlStateValueOn;
//set filter search type
NSString* filterSearchType = [NSUserDefaults.standardUserDefaults stringForKey:@"FilterSearchType"];
@ -167,8 +167,8 @@
if (sender != prevFilterButton)
{
prevFilterButton.state = NSOffState;
[sender setState:NSOnState];
prevFilterButton.state = NSControlStateValueOff;
[sender setState:NSControlStateValueOn];
NSString* filterType;
if (sender == fActiveFilterButton)
@ -196,7 +196,7 @@
}
else
{
[sender setState:NSOnState];
[sender setState:NSControlStateValueOn];
}
[NSNotificationCenter.defaultCenter postNotificationName:@"ApplyFilter" object:nil];
@ -366,13 +366,15 @@
state = [filterType isEqualToString:FILTER_TYPE_NAME];
}
menuItem.state = state ? NSOnState : NSOffState;
menuItem.state = state ? NSControlStateValueOn : NSControlStateValueOff;
return YES;
}
if (action == @selector(setGroupFilter:))
{
menuItem.state = menuItem.tag == [NSUserDefaults.standardUserDefaults integerForKey:@"FilterGroup"] ? NSOnState : NSOffState;
menuItem.state = menuItem.tag == [NSUserDefaults.standardUserDefaults integerForKey:@"FilterGroup"]
? NSControlStateValueOn
: NSControlStateValueOff;
return YES;
}

View File

@ -222,7 +222,7 @@
[panel beginSheetModalForWindow:fCustomLocationPopUp.window completionHandler:^(NSInteger result) {
NSInteger const index = [GroupsController.groups indexForRow:fTableView.selectedRow];
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
NSString* path = panel.URLs[0].path;
[GroupsController.groups setCustomDownloadLocation:path forIndex:index];
@ -245,7 +245,7 @@
- (IBAction)toggleUseCustomDownloadLocation:(id)sender
{
NSInteger index = [GroupsController.groups indexForRow:fTableView.selectedRow];
if (fCustomLocationEnableCheck.state == NSOnState)
if (fCustomLocationEnableCheck.state == NSControlStateValueOn)
{
if ([GroupsController.groups customDownloadLocationForIndex:index])
{
@ -261,7 +261,7 @@
[GroupsController.groups setUsesCustomDownloadLocation:NO forIndex:index];
}
fCustomLocationPopUp.enabled = (fCustomLocationEnableCheck.state == NSOnState);
fCustomLocationPopUp.enabled = (fCustomLocationEnableCheck.state == NSControlStateValueOn);
}
#pragma mark -
@ -270,7 +270,7 @@
- (IBAction)toggleUseAutoAssignRules:(id)sender
{
NSInteger index = [GroupsController.groups indexForRow:fTableView.selectedRow];
if (fAutoAssignRulesEnableCheck.state == NSOnState)
if (fAutoAssignRulesEnableCheck.state == NSControlStateValueOn)
{
if ([GroupsController.groups autoAssignRulesForIndex:index])
{
@ -286,7 +286,7 @@
[GroupsController.groups setUsesAutoAssignRules:NO forIndex:index];
}
fAutoAssignRulesEditButton.enabled = fAutoAssignRulesEnableCheck.state == NSOnState;
fAutoAssignRulesEditButton.enabled = fAutoAssignRulesEnableCheck.state == NSControlStateValueOn;
}
- (IBAction)orderFrontRulesSheet:(id)sender
@ -334,7 +334,7 @@
[GroupsController.groups setAutoAssignRules:predicate forIndex:index];
fAutoAssignRulesEnableCheck.state = [GroupsController.groups usesAutoAssignRulesForIndex:index];
fAutoAssignRulesEditButton.enabled = fAutoAssignRulesEnableCheck.state == NSOnState;
fAutoAssignRulesEditButton.enabled = fAutoAssignRulesEnableCheck.state == NSControlStateValueOn;
}
- (void)ruleEditorRowsDidChange:(NSNotification*)notification
@ -370,7 +370,7 @@
fAutoAssignRulesEnableCheck.state = [GroupsController.groups usesAutoAssignRulesForIndex:index];
fAutoAssignRulesEnableCheck.enabled = YES;
fAutoAssignRulesEditButton.enabled = (fAutoAssignRulesEnableCheck.state == NSOnState);
fAutoAssignRulesEditButton.enabled = (fAutoAssignRulesEnableCheck.state == NSControlStateValueOn);
}
else
{

View File

@ -107,7 +107,7 @@
{
NSInteger const filesCheckState = [torrent
checkForFiles:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, torrent.fileCount)]];
fCheckAllButton.enabled = filesCheckState != NSOnState; //if anything is unchecked
fCheckAllButton.enabled = filesCheckState != NSControlStateValueOn; //if anything is unchecked
fUncheckAllButton.enabled = !torrent.allDownloaded; //if there are any checked files that aren't finished
}
}

View File

@ -98,19 +98,21 @@
NSEnumerator* enumerator = [fTorrents objectEnumerator];
Torrent* torrent = [enumerator nextObject]; //first torrent
NSInteger uploadUseSpeedLimit = [torrent usesSpeedLimit:YES] ? NSOnState : NSOffState;
NSInteger uploadUseSpeedLimit = [torrent usesSpeedLimit:YES] ? NSControlStateValueOn : NSControlStateValueOff;
NSInteger uploadSpeedLimit = [torrent speedLimit:YES];
NSInteger downloadUseSpeedLimit = [torrent usesSpeedLimit:NO] ? NSOnState : NSOffState;
NSInteger downloadUseSpeedLimit = [torrent usesSpeedLimit:NO] ? NSControlStateValueOn : NSControlStateValueOff;
NSInteger downloadSpeedLimit = [torrent speedLimit:NO];
NSInteger globalUseSpeedLimit = torrent.usesGlobalSpeedLimit ? NSOnState : NSOffState;
NSInteger globalUseSpeedLimit = torrent.usesGlobalSpeedLimit ? NSControlStateValueOn : NSControlStateValueOff;
while ((torrent = [enumerator nextObject]) &&
(uploadUseSpeedLimit != NSMixedState || uploadSpeedLimit != INVALID || downloadUseSpeedLimit != NSMixedState ||
downloadSpeedLimit != INVALID || globalUseSpeedLimit != NSMixedState))
(uploadUseSpeedLimit != NSControlStateValueMixed || uploadSpeedLimit != INVALID ||
downloadUseSpeedLimit != NSControlStateValueMixed || downloadSpeedLimit != INVALID ||
globalUseSpeedLimit != NSControlStateValueMixed))
{
if (uploadUseSpeedLimit != NSMixedState && uploadUseSpeedLimit != ([torrent usesSpeedLimit:YES] ? NSOnState : NSOffState))
if (uploadUseSpeedLimit != NSControlStateValueMixed &&
uploadUseSpeedLimit != ([torrent usesSpeedLimit:YES] ? NSControlStateValueOn : NSControlStateValueOff))
{
uploadUseSpeedLimit = NSMixedState;
uploadUseSpeedLimit = NSControlStateValueMixed;
}
if (uploadSpeedLimit != INVALID && uploadSpeedLimit != [torrent speedLimit:YES])
@ -118,9 +120,10 @@
uploadSpeedLimit = INVALID;
}
if (downloadUseSpeedLimit != NSMixedState && downloadUseSpeedLimit != ([torrent usesSpeedLimit:NO] ? NSOnState : NSOffState))
if (downloadUseSpeedLimit != NSControlStateValueMixed &&
downloadUseSpeedLimit != ([torrent usesSpeedLimit:NO] ? NSControlStateValueOn : NSControlStateValueOff))
{
downloadUseSpeedLimit = NSMixedState;
downloadUseSpeedLimit = NSControlStateValueMixed;
}
if (downloadSpeedLimit != INVALID && downloadSpeedLimit != [torrent speedLimit:NO])
@ -128,9 +131,10 @@
downloadSpeedLimit = INVALID;
}
if (globalUseSpeedLimit != NSMixedState && globalUseSpeedLimit != (torrent.usesGlobalSpeedLimit ? NSOnState : NSOffState))
if (globalUseSpeedLimit != NSControlStateValueMixed &&
globalUseSpeedLimit != (torrent.usesGlobalSpeedLimit ? NSControlStateValueOn : NSControlStateValueOff))
{
globalUseSpeedLimit = NSMixedState;
globalUseSpeedLimit = NSControlStateValueMixed;
}
}
@ -138,8 +142,8 @@
fUploadLimitCheck.state = uploadUseSpeedLimit;
fUploadLimitCheck.enabled = YES;
fUploadLimitLabel.enabled = uploadUseSpeedLimit == NSOnState;
fUploadLimitField.enabled = uploadUseSpeedLimit == NSOnState;
fUploadLimitLabel.enabled = uploadUseSpeedLimit == NSControlStateValueOn;
fUploadLimitField.enabled = uploadUseSpeedLimit == NSControlStateValueOn;
if (uploadSpeedLimit != INVALID)
{
fUploadLimitField.intValue = uploadSpeedLimit;
@ -153,8 +157,8 @@
fDownloadLimitCheck.state = downloadUseSpeedLimit;
fDownloadLimitCheck.enabled = YES;
fDownloadLimitLabel.enabled = downloadUseSpeedLimit == NSOnState;
fDownloadLimitField.enabled = downloadUseSpeedLimit == NSOnState;
fDownloadLimitLabel.enabled = downloadUseSpeedLimit == NSControlStateValueOn;
fDownloadLimitField.enabled = downloadUseSpeedLimit == NSControlStateValueOn;
if (downloadSpeedLimit != INVALID)
{
fDownloadLimitField.intValue = downloadSpeedLimit;
@ -174,7 +178,8 @@
NSInteger checkRatio = torrent.ratioSetting;
NSInteger checkIdle = torrent.idleSetting;
NSInteger removeWhenFinishSeeding = torrent.removeWhenFinishSeeding ? NSOnState : NSOffState;
NSInteger removeWhenFinishSeeding = torrent.removeWhenFinishSeeding ? NSControlStateValueOn
: NSControlStateValueOff;
CGFloat ratioLimit = torrent.ratioLimit;
NSUInteger idleLimit = torrent.idleLimitMinutes;
@ -201,9 +206,11 @@
idleLimit = INVALID;
}
if (removeWhenFinishSeeding != NSMixedState && removeWhenFinishSeeding != (torrent.removeWhenFinishSeeding ? NSOnState : NSOffState))
if (removeWhenFinishSeeding != NSControlStateValueMixed &&
removeWhenFinishSeeding != (torrent.removeWhenFinishSeeding ? NSControlStateValueOn
: NSControlStateValueOff))
{
removeWhenFinishSeeding = NSMixedState;
removeWhenFinishSeeding = NSControlStateValueMixed;
}
}
@ -343,11 +350,11 @@
{
BOOL const upload = sender == fUploadLimitCheck;
if (((NSButton*)sender).state == NSMixedState)
if (((NSButton*)sender).state == NSControlStateValueMixed)
{
[sender setState:NSOnState];
[sender setState:NSControlStateValueOn];
}
BOOL const limit = ((NSButton*)sender).state == NSOnState;
BOOL const limit = ((NSButton*)sender).state == NSControlStateValueOn;
for (Torrent* torrent in fTorrents)
{
@ -370,11 +377,11 @@
- (void)setUseGlobalSpeedLimit:(id)sender
{
if (((NSButton*)sender).state == NSMixedState)
if (((NSButton*)sender).state == NSControlStateValueMixed)
{
[sender setState:NSOnState];
[sender setState:NSControlStateValueOn];
}
BOOL const limit = ((NSButton*)sender).state == NSOnState;
BOOL const limit = ((NSButton*)sender).state == NSControlStateValueOn;
for (Torrent* torrent in fTorrents)
{
@ -500,11 +507,11 @@
- (IBAction)setRemoveWhenSeedingCompletes:(id)sender
{
if (((NSButton*)sender).state == NSMixedState)
if (((NSButton*)sender).state == NSControlStateValueMixed)
{
[sender setState:NSOnState];
[sender setState:NSControlStateValueOn];
}
BOOL const enable = ((NSButton*)sender).state == NSOnState;
BOOL const enable = ((NSButton*)sender).state == NSControlStateValueOn;
for (Torrent* torrent in fTorrents)
{
@ -582,19 +589,19 @@
if (fTorrents.count == 0)
{
fUploadLimitCheck.enabled = NO;
fUploadLimitCheck.state = NSOffState;
fUploadLimitCheck.state = NSControlStateValueOff;
fUploadLimitField.enabled = NO;
fUploadLimitLabel.enabled = NO;
fUploadLimitField.stringValue = @"";
fDownloadLimitCheck.enabled = NO;
fDownloadLimitCheck.state = NSOffState;
fDownloadLimitCheck.state = NSControlStateValueOff;
fDownloadLimitField.enabled = NO;
fDownloadLimitLabel.enabled = NO;
fDownloadLimitField.stringValue = @"";
fGlobalLimitCheck.enabled = NO;
fGlobalLimitCheck.state = NSOffState;
fGlobalLimitCheck.state = NSControlStateValueOff;
fPriorityPopUp.enabled = NO;
[fPriorityPopUp selectItemAtIndex:-1];
@ -613,7 +620,7 @@
fIdleLimitGlobalLabel.hidden = YES;
fRemoveSeedingCompleteCheck.enabled = NO;
fRemoveSeedingCompleteCheck.state = NSOffState;
fRemoveSeedingCompleteCheck.state = NSControlStateValueOff;
fPeersConnectField.enabled = NO;
fPeersConnectField.stringValue = @"";

View File

@ -139,7 +139,7 @@
iconSize.width,
iconSize.height);
[fIcon drawInRect:iconRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
[fIcon drawInRect:iconRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0];
}
[tabImage unlockFocus];

View File

@ -433,7 +433,7 @@
alert.showsSuppressionButton = YES;
NSInteger result = [alert runModal];
if (alert.suppressionButton.state == NSOnState)
if (alert.suppressionButton.state == NSControlStateValueOn)
{
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"WarningRemoveTrackers"];
}

View File

@ -404,7 +404,7 @@
panel.nameFieldStringValue = NSLocalizedString(@"untitled", "Save log panel -> default file name");
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
//make the array sorted by date
NSSortDescriptor* descriptor = [NSSortDescriptor sortDescriptorWithKey:@"Index" ascending:YES];
@ -428,7 +428,7 @@
alert.informativeText = [NSString
stringWithFormat:NSLocalizedString(@"There was a problem creating the file \"%@\".", "Save log alert panel -> message"),
panel.URL.path.lastPathComponent];
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert runModal];
}

View File

@ -33,7 +33,7 @@
[color set];
NSSize const size = coloredImage.size;
NSRectFillUsingOperation(NSMakeRect(0.0, 0.0, size.width, size.height), NSCompositeSourceAtop);
NSRectFillUsingOperation(NSMakeRect(0.0, 0.0, size.width, size.height), NSCompositingOperationSourceAtop);
[coloredImage unlockFocus];

View File

@ -45,7 +45,7 @@
if (!fAttributes)
{
NSMutableParagraphStyle* paragraphStyle = [NSParagraphStyle.defaultParagraphStyle mutableCopy];
paragraphStyle.alignment = NSRightTextAlignment;
paragraphStyle.alignment = NSTextAlignmentRight;
fAttributes = @{
NSFontAttributeName : [NSFont systemFontOfSize:11.0],
@ -76,7 +76,7 @@
imageSize.width,
imageSize.height);
[checkImage drawInRect:rect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES
[checkImage drawInRect:rect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES
hints:nil];
}
}

View File

@ -428,7 +428,7 @@
- (void)setRandomPortOnStart:(id)sender
{
tr_sessionSetPeerPortRandomOnStart(fHandle, ((NSButton*)sender).state == NSOnState);
tr_sessionSetPeerPortRandomOnStart(fHandle, ((NSButton*)sender).state == NSControlStateValueOn);
}
- (void)setNat:(id)sender
@ -892,7 +892,7 @@
panel.canCreateDirectories = YES;
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
[fFolderPopUp selectItemAtIndex:DOWNLOAD_FOLDER];
@ -923,7 +923,7 @@
panel.canCreateDirectories = YES;
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
NSString* folder = panel.URLs[0].path;
[fDefaults setObject:folder forKey:@"IncompleteDownloadFolder"];
@ -946,7 +946,7 @@
panel.canCreateDirectories = NO;
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
NSString* filePath = panel.URLs[0].path;
@ -974,7 +974,7 @@
- (void)setShowAddMagnetWindow:(id)sender
{
[fDefaults setBool:(fShowMagnetAddWindowCheck.state == NSOnState) forKey:@"MagnetOpenAsk"];
[fDefaults setBool:(fShowMagnetAddWindowCheck.state == NSControlStateValueOn) forKey:@"MagnetOpenAsk"];
}
- (void)updateShowAddMagnetWindowField
@ -982,7 +982,7 @@
if (![fDefaults boolForKey:@"DownloadLocationConstant"])
{
//always show the add window for magnet links when the download location is the same as the torrent file
fShowMagnetAddWindowCheck.state = NSOnState;
fShowMagnetAddWindowCheck.state = NSControlStateValueOn;
fShowMagnetAddWindowCheck.enabled = NO;
}
else
@ -1039,7 +1039,7 @@
panel.canCreateDirectories = YES;
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
if (result == NSModalResponseOK)
{
VDKQueue* watcherQueue = ((Controller*)NSApp.delegate).fileWatcherQueue;
[watcherQueue removeAllPaths];

View File

@ -20,7 +20,7 @@ NSString* generateIconData(NSString* fileExtension, NSUInteger width, NSMutableD
NSRect const iconFrame = NSMakeRect(0.0, 0.0, width, width);
NSImage* renderedIcon = [[NSImage alloc] initWithSize:iconFrame.size];
[renderedIcon lockFocus];
[icon drawInRect:iconFrame fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
[icon drawInRect:iconFrame fromRect:NSZeroRect operation:NSCompositingOperationCopy fraction:1.0];
[renderedIcon unlockFocus];
NSData* iconData = [renderedIcon TIFFRepresentation];

View File

@ -145,7 +145,7 @@ tr_session* fLib = NULL;
@"This will clear the global statistics displayed by Transmission."
" Individual transfer statistics will not be affected.",
"Stats reset -> message");
alert.alertStyle = NSWarningAlertStyle;
alert.alertStyle = NSAlertStyleWarning;
[alert addButtonWithTitle:NSLocalizedString(@"Reset", "Stats reset -> button")];
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Stats reset -> button")];
alert.showsSuppressionButton = YES;
@ -153,7 +153,7 @@ tr_session* fLib = NULL;
[alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) {
[alert.window orderOut:nil];
if (alert.suppressionButton.state == NSOnState)
if (alert.suppressionButton.state == NSControlStateValueOn)
{
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"WarningResetStats"];
}

View File

@ -245,7 +245,9 @@ typedef NS_ENUM(unsigned int, statusTag) {
statusLabel = STATUS_RATIO_TOTAL;
}
menuItem.state = [statusLabel isEqualToString:[NSUserDefaults.standardUserDefaults stringForKey:@"StatusLabel"]] ? NSOnState : NSOffState;
menuItem.state = [statusLabel isEqualToString:[NSUserDefaults.standardUserDefaults stringForKey:@"StatusLabel"]]
? NSControlStateValueOn
: NSControlStateValueOff;
return YES;
}

View File

@ -27,7 +27,7 @@
//when the toolbar is set to small size, don't make the group items small
- (NSControlSize)controlSize
{
return NSRegularControlSize;
return NSControlSizeRegular;
}
@end

View File

@ -257,13 +257,13 @@ bool trashDataFile(char const* filename, tr_error** error)
{
switch (ratioSetting.intValue)
{
case NSOnState:
case NSControlStateValueOn:
self.ratioSetting = TR_RATIOLIMIT_SINGLE;
break;
case NSOffState:
case NSControlStateValueOff:
self.ratioSetting = TR_RATIOLIMIT_UNLIMITED;
break;
case NSMixedState:
case NSControlStateValueMixed:
self.ratioSetting = TR_RATIOLIMIT_GLOBAL;
break;
}
@ -691,7 +691,7 @@ bool trashDataFile(char const* filename, tr_error** error)
alert.suppressionButton.title = NSLocalizedString(@"Do not check disk space again", "Torrent disk space alert -> button");
NSInteger const result = [alert runModal];
if (alert.suppressionButton.state == NSOnState)
if (alert.suppressionButton.state == NSControlStateValueOn)
{
[fDefaults setBool:NO forKey:@"WarningRemainingSpace"];
}
@ -1620,10 +1620,10 @@ bool trashDataFile(char const* filename, tr_error** error)
if (onState && offState)
{
return NSMixedState;
return NSControlStateValueMixed;
}
}
return onState ? NSOnState : NSOffState;
return onState ? NSControlStateValueOn : NSControlStateValueOff;
}
- (void)setFileCheckState:(NSInteger)state forIndexes:(NSIndexSet*)indexSet
@ -1635,7 +1635,7 @@ bool trashDataFile(char const* filename, tr_error** error)
files[i] = index;
}
tr_torrentSetFileDLs(fHandle, files, count, state != NSOffState);
tr_torrentSetFileDLs(fHandle, files, count, state != NSControlStateValueOff);
free(files);
[self update];

View File

@ -162,7 +162,7 @@
[(TorrentTableView*)controlView removeTrackingAreas];
while (event.type != NSLeftMouseUp)
while (event.type != NSEventTypeLeftMouseUp)
{
point = [controlView convertPoint:event.locationInWindow fromView:nil];
@ -186,12 +186,14 @@
}
//send events to where necessary
if (event.type == NSMouseEntered || event.type == NSMouseExited)
if (event.type == NSEventTypeMouseEntered || event.type == NSEventTypeMouseExited)
{
[NSApp sendEvent:event];
}
event = [controlView.window
nextEventMatchingMask:(NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask)];
event = [controlView.window nextEventMatchingMask:(NSEventMaskLeftMouseUp |
NSEventMaskLeftMouseDragged |
NSEventMaskMouseEntered |
NSEventMaskMouseExited)];
}
fTracking = NO;
@ -359,7 +361,7 @@
if (!minimal || !(!fTracking && fHoverAction)) //don't show in minimal mode when hovered over
{
NSImage* icon = (minimal && error) ? [NSImage imageNamed:NSImageNameCaution] : torrent.icon;
[icon drawInRect:iconRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];
[icon drawInRect:iconRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES hints:nil];
}
//error badge
@ -367,13 +369,13 @@
{
NSImage* errorImage = [NSImage imageNamed:NSImageNameCaution];
NSRect const errorRect = NSMakeRect(NSMaxX(iconRect) - ERROR_IMAGE_SIZE, NSMaxY(iconRect) - ERROR_IMAGE_SIZE, ERROR_IMAGE_SIZE, ERROR_IMAGE_SIZE);
[errorImage drawInRect:errorRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES
[errorImage drawInRect:errorRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES
hints:nil];
}
//text color
NSColor *titleColor, *statusColor;
if (self.backgroundStyle == NSBackgroundStyleDark)
if (self.backgroundStyle == NSBackgroundStyleEmphasized)
{
titleColor = statusColor = NSColor.whiteColor;
}
@ -434,7 +436,7 @@
}
else
{
if (NSApp.currentEvent.modifierFlags & NSAlternateKeyMask)
if (NSApp.currentEvent.modifierFlags & NSEventModifierFlagOption)
{
controlImage = [NSImage imageNamed:[@"ResumeNoWait" stringByAppendingString:controlImageSuffix]];
}
@ -449,7 +451,7 @@
}
NSRect const controlRect = [self controlButtonRectForBounds:cellFrame];
[controlImage drawInRect:controlRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES
[controlImage drawInRect:controlRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES
hints:nil];
minimalTitleRightBound = MIN(minimalTitleRightBound, NSMinX(controlRect));
@ -469,7 +471,7 @@
}
NSImage* revealImage = [NSImage imageNamed:revealImageString];
[revealImage drawInRect:[self revealButtonRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositeSourceOver
[revealImage drawInRect:[self revealButtonRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositingOperationSourceOver
fraction:1.0
respectFlipped:YES
hints:nil];
@ -495,7 +497,7 @@
{
NSImage* actionImage = [NSImage imageNamed:actionImageString];
[actionImage drawInRect:[self actionButtonRectForBounds:cellFrame] fromRect:NSZeroRect
operation:NSCompositeSourceOver
operation:NSCompositingOperationSourceOver
fraction:1.0
respectFlipped:YES
hints:nil];
@ -516,11 +518,12 @@
PRIORITY_ICON_WIDTH,
PRIORITY_ICON_HEIGHT);
NSColor* priorityColor = self.backgroundStyle == NSBackgroundStyleDark ? NSColor.whiteColor : NSColor.labelColor;
NSColor* priorityColor = self.backgroundStyle == NSBackgroundStyleEmphasized ? NSColor.whiteColor
: NSColor.labelColor;
NSImage* priorityImage = [[NSImage imageNamed:(torrent.priority == TR_PRI_HIGH ? @"PriorityHighTemplate" : @"PriorityLowTemplate")]
imageWithColor:priorityColor];
[priorityImage drawInRect:priorityRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0
[priorityImage drawInRect:priorityRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0
respectFlipped:YES
hints:nil];
}
@ -697,7 +700,7 @@
if (torrent.magnet)
{
[[NSColor colorWithCalibratedWhite:1.0 alpha:[fDefaults boolForKey:@"SmallView"] ? 0.25 : 1.0] set];
NSRectFillUsingOperation(barRect, NSCompositeSourceOver);
NSRectFillUsingOperation(barRect, NSCompositingOperationSourceOver);
return;
}
@ -746,7 +749,7 @@
torrent.previousFinishedPieces = finishedIndexes.count > 0 ? finishedIndexes : nil; //don't bother saving if none are complete
//actually draw image
[bitmap drawInRect:barRect fromRect:NSZeroRect operation:NSCompositeSourceOver
[bitmap drawInRect:barRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver
fraction:([fDefaults boolForKey:@"SmallView"] ? 0.25 : 1.0)respectFlipped:YES
hints:nil];
}
@ -911,7 +914,7 @@
return NSLocalizedString(@"Pause the transfer", "Torrent Table -> tooltip");
else
{
if (NSApp.currentEvent.modifierFlags & NSAlternateKeyMask)
if (NSApp.currentEvent.modifierFlags & NSEventModifierFlagOption)
{
return NSLocalizedString(@"Resume the transfer right away", "Torrent cell -> button info");
}

View File

@ -593,7 +593,9 @@
{
unichar const firstChar = [event.charactersIgnoringModifiers characterAtIndex:0];
if (firstChar == 'f' && event.modifierFlags & NSAlternateKeyMask && event.modifierFlags & NSCommandKeyMask)
if (firstChar == 'f' &&
event.modifierFlags & NSEventModifierFlagOption &&
event.modifierFlags & NSEventModifierFlagCommand)
{
[fController focusFilterField];
}
@ -688,7 +690,7 @@
}
else
{
if (NSEvent.modifierFlags & NSAlternateKeyMask)
if (NSEvent.modifierFlags & NSEventModifierFlagOption)
{
[fController resumeTorrentsNoWait:@[ torrent ]];
}
@ -776,12 +778,12 @@
BOOL const limit = [fMenuTorrent usesSpeedLimit:upload];
item = [menu itemWithTag:ACTION_MENU_LIMIT_TAG];
item.state = limit ? NSOnState : NSOffState;
item.state = limit ? NSControlStateValueOn : NSControlStateValueOff;
item.title = [NSString stringWithFormat:NSLocalizedString(@"Limit (%d KB/s)", "torrent action menu -> upload/download limit"),
[fMenuTorrent speedLimit:upload]];
item = [menu itemWithTag:ACTION_MENU_UNLIMITED_TAG];
item.state = !limit ? NSOnState : NSOffState;
item.state = !limit ? NSControlStateValueOn : NSControlStateValueOff;
}
else if (menu == fRatioMenu)
{
@ -804,28 +806,28 @@
tr_ratiolimit const mode = fMenuTorrent.ratioSetting;
item = [menu itemWithTag:ACTION_MENU_LIMIT_TAG];
item.state = mode == TR_RATIOLIMIT_SINGLE ? NSOnState : NSOffState;
item.state = mode == TR_RATIOLIMIT_SINGLE ? NSControlStateValueOn : NSControlStateValueOff;
item.title = [NSString localizedStringWithFormat:NSLocalizedString(@"Stop at Ratio (%.2f)", "torrent action menu -> ratio stop"),
fMenuTorrent.ratioLimit];
item = [menu itemWithTag:ACTION_MENU_UNLIMITED_TAG];
item.state = mode == TR_RATIOLIMIT_UNLIMITED ? NSOnState : NSOffState;
item.state = mode == TR_RATIOLIMIT_UNLIMITED ? NSControlStateValueOn : NSControlStateValueOff;
item = [menu itemWithTag:ACTION_MENU_GLOBAL_TAG];
item.state = mode == TR_RATIOLIMIT_GLOBAL ? NSOnState : NSOffState;
item.state = mode == TR_RATIOLIMIT_GLOBAL ? NSControlStateValueOn : NSControlStateValueOff;
}
else if (menu == fPriorityMenu)
{
tr_priority_t const priority = fMenuTorrent.priority;
NSMenuItem* item = [menu itemWithTag:ACTION_MENU_PRIORITY_HIGH_TAG];
item.state = priority == TR_PRI_HIGH ? NSOnState : NSOffState;
item.state = priority == TR_PRI_HIGH ? NSControlStateValueOn : NSControlStateValueOff;
item = [menu itemWithTag:ACTION_MENU_PRIORITY_NORMAL_TAG];
item.state = priority == TR_PRI_NORMAL ? NSOnState : NSOffState;
item.state = priority == TR_PRI_NORMAL ? NSControlStateValueOn : NSControlStateValueOff;
item = [menu itemWithTag:ACTION_MENU_PRIORITY_LOW_TAG];
item.state = priority == TR_PRI_LOW ? NSOnState : NSOffState;
item.state = priority == TR_PRI_LOW ? NSControlStateValueOn : NSControlStateValueOff;
}
}
@ -849,7 +851,7 @@
- (void)setGlobalLimit:(id)sender
{
fMenuTorrent.usesGlobalSpeedLimit = ((NSButton*)sender).state != NSOnState;
fMenuTorrent.usesGlobalSpeedLimit = ((NSButton*)sender).state != NSControlStateValueOn;
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateOptions" object:nil];
}

View File

@ -97,14 +97,14 @@ NSMutableSet* fTrackerIconLoading;
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
{
//icon
[self.favIcon drawInRect:[self imageRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositeSourceOver
[self.favIcon drawInRect:[self imageRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositingOperationSourceOver
fraction:1.0
respectFlipped:YES
hints:nil];
//set table colors
NSColor *nameColor, *statusColor;
if (self.backgroundStyle == NSBackgroundStyleDark)
if (self.backgroundStyle == NSBackgroundStyleEmphasized)
{
nameColor = statusColor = NSColor.whiteColor;
}