Fix code_style.sh to include *.mm files after switch to Obj-C++ (#2846)

This commit is contained in:
Mike Gelfand 2022-03-31 00:52:23 +03:00 committed by GitHub
parent e4461c48d7
commit d943f069f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 243 additions and 241 deletions

View File

@ -20,6 +20,7 @@ cfile_includes=(
'*.cc'
'*.h'
'*.m'
'*.mm'
)
cfile_excludes=(
'build/*'

View File

@ -36,11 +36,11 @@ AboutWindowController* fAboutBoxInstance = nil;
self.fVersionField.stringValue = @(LONG_VERSION_STRING);
self.fCopyrightField.stringValue = [NSBundle.mainBundle localizedStringForKey:@"NSHumanReadableCopyright" value:nil
table:@"InfoPlist"];
table:@"InfoPlist"];
[self.fTextView.textStorage setAttributedString:[[NSAttributedString alloc] initWithPath:[NSBundle.mainBundle pathForResource:@"Credits"
ofType:@"rtf"]
documentAttributes:nil]];
[self.fTextView.textStorage
setAttributedString:[[NSAttributedString alloc] initWithPath:[NSBundle.mainBundle pathForResource:@"Credits" ofType:@"rtf"]
documentAttributes:nil]];
//size license button
CGFloat const oldButtonWidth = NSWidth(self.fLicenseButton.frame);

View File

@ -95,8 +95,8 @@
}
[self.fPriorityPopUp selectItemAtIndex:priorityIndex];
self.fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSControlStateValueOn
: NSControlStateValueOff;
self.fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSControlStateValueOn :
NSControlStateValueOff;
if (self.fDestination)
{

View File

@ -146,8 +146,8 @@
}
[self.fPriorityPopUp selectItemAtIndex:priorityIndex];
self.fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSControlStateValueOn
: NSControlStateValueOff;
self.fStartCheck.state = [NSUserDefaults.standardUserDefaults boolForKey:@"AutoStartDownload"] ? NSControlStateValueOn :
NSControlStateValueOff;
self.fDeleteCheck.state = self.fDeleteTorrentEnableInitially ? NSControlStateValueOn : NSControlStateValueOff;
self.fDeleteCheck.enabled = self.fCanToggleDelete;
@ -163,8 +163,9 @@
self.fLocationImageView.image = nil;
}
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_SECONDS target:self selector:@selector(updateFiles) userInfo:nil
repeats:YES];
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_SECONDS target:self selector:@selector(updateFiles)
userInfo:nil
repeats:YES];
[self updateFiles];
}

View File

@ -70,11 +70,11 @@ BlocklistDownloader* fBLDownloader = nil;
fBLDownloader = nil;
}
- (void)URLSession:(NSURLSession *)session
downloadTask:(NSURLSessionDownloadTask *)downloadTask
didWriteData:(int64_t)bytesWritten
totalBytesWritten:(int64_t)totalBytesWritten
totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
- (void)URLSession:(NSURLSession*)session
downloadTask:(NSURLSessionDownloadTask*)downloadTask
didWriteData:(int64_t)bytesWritten
totalBytesWritten:(int64_t)totalBytesWritten
totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
{
dispatch_async(dispatch_get_main_queue(), ^{
self.fState = BLOCKLIST_DL_DOWNLOADING;
@ -86,9 +86,7 @@ totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
});
}
- (void)URLSession:(NSURLSession *)session
task:(NSURLSessionTask *)task
didCompleteWithError:(NSError *)error
- (void)URLSession:(NSURLSession*)session task:(NSURLSessionTask*)task didCompleteWithError:(NSError*)error
{
dispatch_async(dispatch_get_main_queue(), ^{
if (error)
@ -103,9 +101,9 @@ didCompleteWithError:(NSError *)error
});
}
- (void)URLSession:(NSURLSession *)session
downloadTask:(NSURLSessionDownloadTask *)downloadTask
didFinishDownloadingToURL:(NSURL *)location
- (void)URLSession:(NSURLSession*)session
downloadTask:(NSURLSessionDownloadTask*)downloadTask
didFinishDownloadingToURL:(NSURL*)location
{
self.fState = BLOCKLIST_DL_PROCESSING;
@ -130,14 +128,12 @@ didFinishDownloadingToURL:(NSURL *)location
}
else
{
[self decompressFrom:[NSURL fileURLWithPath:tempFile]
to:[NSURL fileURLWithPath:blocklistFile]
error:nil];
[self decompressFrom:[NSURL fileURLWithPath:tempFile] to:[NSURL fileURLWithPath:blocklistFile] error:nil];
[NSFileManager.defaultManager removeItemAtPath:tempFile error:nil];
}
dispatch_async(dispatch_get_main_queue(), ^{
const int count = tr_blocklistSetContent(((Controller*)NSApp.delegate).sessionHandle, blocklistFile.UTF8String);
int const count = tr_blocklistSetContent(((Controller*)NSApp.delegate).sessionHandle, blocklistFile.UTF8String);
//delete downloaded file
[NSFileManager.defaultManager removeItemAtPath:blocklistFile error:nil];
@ -148,7 +144,8 @@ didFinishDownloadingToURL:(NSURL *)location
}
else
{
[self.viewController setFailed:NSLocalizedString(@"The specified blocklist file did not contain any valid rules.", "blocklist fail message")];
[self.viewController
setFailed:NSLocalizedString(@"The specified blocklist file did not contain any valid rules.", "blocklist fail message")];
}
//update last updated date for schedule
@ -169,9 +166,8 @@ didFinishDownloadingToURL:(NSURL *)location
{
self.fState = BLOCKLIST_DL_START;
self.fSession = [NSURLSession sessionWithConfiguration:NSURLSessionConfiguration.ephemeralSessionConfiguration
delegate:self
delegateQueue:nil];
self.fSession = [NSURLSession sessionWithConfiguration:NSURLSessionConfiguration.ephemeralSessionConfiguration delegate:self
delegateQueue:nil];
[BlocklistScheduler.scheduler cancelSchedule];
@ -218,11 +214,7 @@ didFinishDownloadingToURL:(NSURL *)location
NSTask* tarList = [[NSTask alloc] init];
tarList.launchPath = @"/usr/bin/tar";
tarList.arguments = @[
@"--list",
@"--file",
file.path
];
tarList.arguments = @[ @"--list", @"--file", file.path ];
NSPipe* pipe = [[NSPipe alloc] init];
tarList.standardOutput = pipe;
@ -242,8 +234,7 @@ didFinishDownloadingToURL:(NSURL *)location
NSData* data = [pipe.fileHandleForReading readDataToEndOfFile];
NSString* output = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSString* output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
filename = [output componentsSeparatedByCharactersInSet:NSCharacterSet.newlineCharacterSet].firstObject;
}
@ -263,12 +254,7 @@ didFinishDownloadingToURL:(NSURL *)location
NSTask* untar = [[NSTask alloc] init];
untar.launchPath = @"/usr/bin/tar";
untar.currentDirectoryPath = destinationDir.path;
untar.arguments = @[
@"--extract",
@"--file",
file.path,
filename
];
untar.arguments = @[ @"--extract", @"--file", file.path, filename ];
@try
{
@ -298,10 +284,7 @@ didFinishDownloadingToURL:(NSURL *)location
NSTask* gunzip = [[NSTask alloc] init];
gunzip.launchPath = @"/usr/bin/gunzip";
gunzip.currentDirectoryPath = destinationDir.path;
gunzip.arguments = @[
@"--keep",
file.path
];
gunzip.arguments = @[ @"--keep", file.path ];
@try
{
@ -313,7 +296,7 @@ didFinishDownloadingToURL:(NSURL *)location
return NO;
}
}
@catch (NSException *exception)
@catch (NSException* exception)
{
return NO;
}
@ -350,12 +333,11 @@ didFinishDownloadingToURL:(NSURL *)location
NSData* data = [pipe.fileHandleForReading readDataToEndOfFile];
NSString* output = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSString* output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
filename = [output componentsSeparatedByCharactersInSet:NSCharacterSet.newlineCharacterSet].firstObject;
}
@catch (NSException *exception)
@catch (NSException* exception)
{
return NO;
}
@ -371,10 +353,7 @@ didFinishDownloadingToURL:(NSURL *)location
NSTask* unzip = [[NSTask alloc] init];
unzip.launchPath = @"/usr/bin/unzip";
unzip.currentDirectoryPath = destinationDir.path;
unzip.arguments = @[
file.path,
filename
];
unzip.arguments = @[ file.path, filename ];
@try
{
@ -386,7 +365,7 @@ didFinishDownloadingToURL:(NSURL *)location
return NO;
}
}
@catch (NSException *exception)
@catch (NSException* exception)
{
return NO;
}

View File

@ -13,7 +13,7 @@
@interface BlocklistScheduler ()
@property (nonatomic) NSTimer* fTimer;
@property(nonatomic) NSTimer* fTimer;
- (void)runUpdater;
@ -58,7 +58,7 @@ BlocklistScheduler* fScheduler = nil;
NSDate* useDate = lastUpdateDate ? [lastUpdateDate laterDate:closeDate] : closeDate;
self.fTimer = [[NSTimer alloc] initWithFireDate:useDate interval:0 target:self selector:@selector(runUpdater) userInfo:nil
repeats:NO];
repeats:NO];
//current run loop usually means a second update won't work
NSRunLoop* loop = NSRunLoop.mainRunLoop;

View File

@ -646,7 +646,7 @@ static void removeKeRangerRansomware()
{
NSLog(@"Could not IORegisterForSystemPower");
}
auto* const session = self.fLib;
//load previous transfers
@ -655,7 +655,7 @@ static void removeKeRangerRansomware()
int n_torrents = 0;
tr_torrent** loaded_torrents = tr_sessionLoadTorrents(session, ctor, &n_torrents);
tr_ctorFree(ctor);
// process the loaded torrents
for (int i = 0; i < n_torrents; ++i)
{
@ -669,8 +669,7 @@ static void removeKeRangerRansomware()
[self.fTorrents addObject:torrent];
self.fTorrentHashes[torrent.hashString] = torrent;
}
//update previous transfers state by recreating a torrent from history
//and comparing to torrents already loaded via tr_sessionLoadTorrents
NSString* historyFile = [self.fConfigDirectory stringByAppendingPathComponent:TRANSFER_PLIST];
@ -690,14 +689,15 @@ static void removeKeRangerRansomware()
NSMutableArray* waitToStartTorrents = [NSMutableArray
arrayWithCapacity:((history.count > 0 && !self.fPauseOnLaunch) ? history.count - 1 : 0)];
Torrent *t = [[Torrent alloc] init];
Torrent* t = [[Torrent alloc] init];
for (NSDictionary* historyItem in history)
{
NSString *hash = historyItem[@"TorrentHash"];
if ([self.fTorrentHashes.allKeys containsObject:hash]) {
Torrent *torrent = self.fTorrentHashes[hash];
NSString* hash = historyItem[@"TorrentHash"];
if ([self.fTorrentHashes.allKeys containsObject:hash])
{
Torrent* torrent = self.fTorrentHashes[hash];
[t setResumeStatusForTorrent:torrent withHistory:historyItem forcePause:self.fPauseOnLaunch];
NSNumber* waitToStart;
if (!self.fPauseOnLaunch && (waitToStart = historyItem[@"WaitToStart"]) && waitToStart.boolValue)
{
@ -758,8 +758,9 @@ static void removeKeRangerRansomware()
//timer to update the interface every second
[self updateUI];
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_UI_SECONDS target:self selector:@selector(updateUI) userInfo:nil
repeats:YES];
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_UI_SECONDS target:self selector:@selector(updateUI)
userInfo:nil
repeats:YES];
[NSRunLoop.currentRunLoop addTimer:self.fTimer forMode:NSModalPanelRunLoopMode];
[NSRunLoop.currentRunLoop addTimer:self.fTimer forMode:NSEventTrackingRunLoopMode];
@ -2137,7 +2138,8 @@ static void removeKeRangerRansomware()
[self.fInfoController updateInfoStats];
[self.fInfoController.window orderFront:nil];
if (self.fInfoController.canQuickLook && [QLPreviewPanel sharedPreviewPanelExists] && [QLPreviewPanel sharedPreviewPanel].visible)
if (self.fInfoController.canQuickLook && [QLPreviewPanel sharedPreviewPanelExists] &&
[QLPreviewPanel sharedPreviewPanel].visible)
{
[[QLPreviewPanel sharedPreviewPanel] reloadData];
}
@ -2303,13 +2305,13 @@ static void removeKeRangerRansomware()
{
__block TorrentGroup* parent = nil;
[self.fDisplayedTorrents enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(TorrentGroup* group, NSUInteger idx, BOOL* stop) {
if ([group.torrents containsObject:torrent])
{
parent = group;
*stop = YES;
}
}];
usingBlock:^(TorrentGroup* group, NSUInteger idx, BOOL* stop) {
if ([group.torrents containsObject:torrent])
{
parent = group;
*stop = YES;
}
}];
if (parent)
{
[[self.fTableView animator] expandItem:parent];
@ -2330,13 +2332,13 @@ static void removeKeRangerRansomware()
{
__block TorrentGroup* parent = nil;
[self.fDisplayedTorrents enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(TorrentGroup* group, NSUInteger idx, BOOL* stop) {
if ([group.torrents containsObject:torrent])
{
parent = group;
*stop = YES;
}
}];
usingBlock:^(TorrentGroup* group, NSUInteger idx, BOOL* stop) {
if ([group.torrents containsObject:torrent])
{
parent = group;
*stop = YES;
}
}];
if (parent)
{
[[self.fTableView animator] expandItem:parent];
@ -2736,7 +2738,7 @@ static void removeKeRangerRansomware()
}
BOOL const filterTracker = searchStrings && [[self.fDefaults stringForKey:@"FilterSearchType"] isEqualToString:FILTER_TYPE_TRACKER];
std::atomic<int32_t> active{0}, downloading{0}, seeding{0}, paused{0}, error{0};
std::atomic<int32_t> active{ 0 }, downloading{ 0 }, seeding{ 0 }, paused{ 0 }, error{ 0 };
// Pointers to be captured by Obj-C Block as const*
auto* activeRef = &active;
auto* downloadingRef = &downloading;
@ -2772,7 +2774,8 @@ static void removeKeRangerRansomware()
}
}
}
else if (torrent.error) {
else if (torrent.error)
{
std::atomic_fetch_add_explicit(errorRef, 1, std::memory_order_relaxed);
if (filterStatus && !filterError)
{
@ -2847,9 +2850,7 @@ static void removeKeRangerRansomware()
//set button tooltips
if (self.fFilterBar)
{
[self.fFilterBar setCountAll:self.fTorrents.count
active:active.load()
downloading:downloading.load()
[self.fFilterBar setCountAll:self.fTorrents.count active:active.load() downloading:downloading.load()
seeding:seeding.load()
paused:paused.load()
error:error.load()];
@ -2906,10 +2907,10 @@ static void removeKeRangerRansomware()
//for each of the torrents to add, find if it already exists (and keep track of those we've already added & those we need to remove)
[allTorrents enumerateObjectsWithOptions:0 usingBlock:^(id objAll, NSUInteger previousIndex, BOOL* stop) {
NSUInteger const currentIndex = [self.fDisplayedTorrents indexOfObjectAtIndexes:removePreviousIndexes
options:NSEnumerationConcurrent
passingTest:^(id objDisplay, NSUInteger idx, BOOL* stop) {
return (BOOL)(objAll == objDisplay);
}];
options:NSEnumerationConcurrent
passingTest:^(id objDisplay, NSUInteger idx, BOOL* stop) {
return (BOOL)(objAll == objDisplay);
}];
if (currentIndex == NSNotFound)
{
[addIndexes addIndex:previousIndex];
@ -2946,12 +2947,12 @@ static void removeKeRangerRansomware()
[addIndexes removeIndexes:newAddIndexes];
[self.fDisplayedTorrents addObjectsFromArray:[allTorrents objectsAtIndexes:newAddIndexes]];
[self.fTableView
insertItemsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(
self.fDisplayedTorrents.count - newAddIndexes.count,
newAddIndexes.count)]
inParent:nil
withAnimation:NSTableViewAnimationSlideLeft];
[self.fTableView insertItemsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(
self.fDisplayedTorrents.count -
newAddIndexes.count,
newAddIndexes.count)]
inParent:nil
withAnimation:NSTableViewAnimationSlideLeft];
}
[self.fDisplayedTorrents addObjectsFromArray:[allTorrents objectsAtIndexes:addIndexes]];
@ -3013,16 +3014,17 @@ static void removeKeRangerRansomware()
groupsByIndex[@(groupValue)] = newGroup;
[self.fDisplayedTorrents addObject:newGroup];
[self.fTableView insertItemsAtIndexes:[NSIndexSet indexSetWithIndex:self.fDisplayedTorrents.count - 1] inParent:nil
withAnimation:NSTableViewAnimationEffectFade];
[self.fTableView insertItemsAtIndexes:[NSIndexSet indexSetWithIndex:self.fDisplayedTorrents.count - 1]
inParent:nil
withAnimation:NSTableViewAnimationEffectFade];
[self.fTableView isGroupCollapsed:groupValue] ? [self.fTableView collapseItem:newGroup] :
[self.fTableView expandItem:newGroup];
[self.fTableView expandItem:newGroup];
}
else //if we haven't processed the other group yet, we have to make sure we don't flag it for removal the next time
{
//ugggh, but shouldn't happen too often
if ([self.fDisplayedTorrents indexOfObject:newGroup
inRange:NSMakeRange(index + 1, originalGroupCount - (index + 1))] != NSNotFound)
inRange:NSMakeRange(index + 1, originalGroupCount - (index + 1))] != NSNotFound)
{
markTorrentAsUsed = NO;
}
@ -3032,7 +3034,7 @@ static void removeKeRangerRansomware()
[newGroup.torrents addObject:torrent];
[self.fTableView moveItemAtIndex:indexInGroup inParent:group toIndex:newGroup.torrents.count - 1
inParent:newGroup];
inParent:newGroup];
--indexInGroup;
}
@ -3063,7 +3065,7 @@ static void removeKeRangerRansomware()
[self.fDisplayedTorrents addObject:group];
[self.fTableView insertItemsAtIndexes:[NSIndexSet indexSetWithIndex:self.fDisplayedTorrents.count - 1] inParent:nil
withAnimation:NSTableViewAnimationEffectFade];
withAnimation:NSTableViewAnimationEffectFade];
[self.fTableView isGroupCollapsed:groupValue] ? [self.fTableView collapseItem:group] : [self.fTableView expandItem:group];
}
@ -3071,7 +3073,7 @@ static void removeKeRangerRansomware()
BOOL const newTorrent = self.fAddingTransfers && [self.fAddingTransfers containsObject:torrent];
[self.fTableView insertItemsAtIndexes:[NSIndexSet indexSetWithIndex:group.torrents.count - 1] inParent:group
withAnimation:newTorrent ? NSTableViewAnimationSlideLeft : NSTableViewAnimationSlideDown];
withAnimation:newTorrent ? NSTableViewAnimationSlideLeft : NSTableViewAnimationSlideDown];
}
//remove empty groups
@ -3107,8 +3109,8 @@ static void removeKeRangerRansomware()
[self.fTableView beginUpdates];
[self.fTableView removeItemsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.fDisplayedTorrents.count)]
inParent:nil
withAnimation:NSTableViewAnimationSlideDown];
inParent:nil
withAnimation:NSTableViewAnimationSlideDown];
if (groupRows)
{
@ -3304,9 +3306,10 @@ static void removeKeRangerRansomware()
}
//check again in 10 seconds in case torrent file wasn't complete
self.fAutoImportTimer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(checkAutoImportDirectory)
userInfo:nil
repeats:NO];
self.fAutoImportTimer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self
selector:@selector(checkAutoImportDirectory)
userInfo:nil
repeats:NO];
[self checkAutoImportDirectory];
}
@ -3794,7 +3797,8 @@ static void removeKeRangerRansomware()
self.fTableView.rowHeight = makeSmall ? ROW_HEIGHT_SMALL : ROW_HEIGHT_REGULAR;
[self.fTableView beginUpdates];
[self.fTableView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.fTableView.numberOfRows)]];
[self.fTableView
noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.fTableView.numberOfRows)]];
[self.fTableView endUpdates];
//resize for larger min height if not set to auto size
@ -3847,7 +3851,8 @@ static void removeKeRangerRansomware()
if (check)
{
//we can't call minSize, since it might be set to the current size (auto size)
CGFloat const minHeight = self.minWindowContentSizeAllowed + (NSHeight(self.fWindow.frame) - NSHeight(self.fWindow.contentView.frame)); //contentView to window
CGFloat const minHeight = self.minWindowContentSizeAllowed +
(NSHeight(self.fWindow.frame) - NSHeight(self.fWindow.contentView.frame)); //contentView to window
if (windowSize.height <= minHeight)
{
@ -4810,8 +4815,7 @@ static void removeKeRangerRansomware()
if (action == @selector(toggleAvailabilityBar:))
{
menuItem.state = [self.fDefaults boolForKey:@"DisplayProgressBarAvailable"] ? NSControlStateValueOn
: NSControlStateValueOff;
menuItem.state = [self.fDefaults boolForKey:@"DisplayProgressBarAvailable"] ? NSControlStateValueOn : NSControlStateValueOff;
return self.fWindow.visible;
}
@ -4819,7 +4823,7 @@ static void removeKeRangerRansomware()
if (action == @selector(showInfo:))
{
NSString* title = self.fInfoController.window.visible ? NSLocalizedString(@"Hide Inspector", "View menu -> Inspector") :
NSLocalizedString(@"Show Inspector", "View menu -> Inspector");
NSLocalizedString(@"Show Inspector", "View menu -> Inspector");
menuItem.title = title;
return YES;
@ -4835,7 +4839,7 @@ static void removeKeRangerRansomware()
if (action == @selector(toggleStatusBar:))
{
NSString* title = !self.fStatusBar ? NSLocalizedString(@"Show Status Bar", "View menu -> Status Bar") :
NSLocalizedString(@"Hide Status Bar", "View menu -> Status Bar");
NSLocalizedString(@"Hide Status Bar", "View menu -> Status Bar");
menuItem.title = title;
return self.fWindow.visible;
@ -4845,7 +4849,7 @@ static void removeKeRangerRansomware()
if (action == @selector(toggleFilterBar:))
{
NSString* title = !self.fFilterBar ? NSLocalizedString(@"Show Filter Bar", "View menu -> Filter Bar") :
NSLocalizedString(@"Hide Filter Bar", "View menu -> Filter Bar");
NSLocalizedString(@"Hide Filter Bar", "View menu -> Filter Bar");
menuItem.title = title;
return self.fWindow.visible;
@ -5104,8 +5108,7 @@ static void removeKeRangerRansomware()
if (action == @selector(setSortReverse:))
{
BOOL const isReverse = menuItem.tag == SORT_DESC_TAG;
menuItem.state = (isReverse == [self.fDefaults boolForKey:@"SortReverse"]) ? NSControlStateValueOn
: NSControlStateValueOff;
menuItem.state = (isReverse == [self.fDefaults boolForKey:@"SortReverse"]) ? NSControlStateValueOn : NSControlStateValueOff;
return ![[self.fDefaults stringForKey:@"Sort"] isEqualToString:SORT_ORDER];
}
@ -5373,13 +5376,13 @@ static void removeKeRangerRansomware()
if (torrentStruct != NULL && (type != TR_RPC_TORRENT_ADDED && type != TR_RPC_SESSION_CHANGED && type != TR_RPC_SESSION_CLOSE))
{
[self.fTorrents enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(Torrent* checkTorrent, NSUInteger idx, BOOL* stop) {
if (torrentStruct == checkTorrent.torrentStruct)
{
torrent = checkTorrent;
*stop = YES;
}
}];
usingBlock:^(Torrent* checkTorrent, NSUInteger idx, BOOL* stop) {
if (torrentStruct == checkTorrent.torrentStruct)
{
torrent = checkTorrent;
*stop = YES;
}
}];
if (!torrent)
{

View File

@ -192,14 +192,16 @@ NSMutableSet* creatorWindowControllerSet = nil;
[self updatePiecesField];
[self.fPieceSizeStepper setIntValue:(int)log2((double)self.fInfo->pieceSize)];
self.fLocation = [[self.fDefaults URLForKey:@"CreatorLocationURL"] URLByAppendingPathComponent:[name stringByAppendingPathExtension:@"torrent"]];
self.fLocation = [[self.fDefaults URLForKey:@"CreatorLocationURL"]
URLByAppendingPathComponent:[name stringByAppendingPathExtension:@"torrent"]];
if (!self.fLocation)
{
//for 2.5 and earlier
#warning we still store "CreatorLocation" in Defaults.plist, and not "CreatorLocationURL"
NSString* location = [self.fDefaults stringForKey:@"CreatorLocation"];
self.fLocation = [[NSURL alloc] initFileURLWithPath:[location.stringByExpandingTildeInPath
stringByAppendingPathComponent:[name stringByAppendingPathExtension:@"torrent"]]];
self.fLocation = [[NSURL alloc]
initFileURLWithPath:[location.stringByExpandingTildeInPath
stringByAppendingPathComponent:[name stringByAppendingPathExtension:@"torrent"]]];
}
[self updateLocationField];
@ -360,7 +362,8 @@ NSMutableSet* creatorWindowControllerSet = nil;
- (IBAction)incrementOrDecrementPieceSize:(id)sender
{
uint32_t pieceSize = (uint32_t)pow(2.0, [sender intValue]);
if (tr_metaInfoBuilderSetPieceSize(self.fInfo, pieceSize)) {
if (tr_metaInfoBuilderSetPieceSize(self.fInfo, pieceSize))
{
[self updatePiecesField];
}
}
@ -513,13 +516,13 @@ NSMutableSet* creatorWindowControllerSet = nil;
if (self.fInfo->pieceCount == 1)
{
self.fPiecesField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"1 piece, %@", "Create torrent -> info"),
[NSString stringForFileSize:self.fInfo->pieceSize]];
[NSString stringForFileSize:self.fInfo->pieceSize]];
}
else
{
self.fPiecesField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%d pieces, %@ each", "Create torrent -> info"),
self.fInfo->pieceCount,
[NSString stringForFileSize:self.fInfo->pieceSize]];
self.fInfo->pieceCount,
[NSString stringForFileSize:self.fInfo->pieceSize]];
}
}
@ -601,9 +604,10 @@ NSMutableSet* creatorWindowControllerSet = nil;
//store values
[self.fDefaults setObject:self.fTrackers forKey:@"CreatorTrackers"];
[self.fDefaults setBool:self.fPrivateCheck.state == NSControlStateValueOn forKey:@"CreatorPrivate"];
[self.fDefaults setObject: [self.fSource stringValue] forKey: @"CreatorSource"];
[self.fDefaults setObject:[self.fSource stringValue] forKey:@"CreatorSource"];
[self.fDefaults setBool:self.fOpenCheck.state == NSControlStateValueOn forKey:@"CreatorOpen"];
self.fOpenWhenCreated = self.fOpenCheck.state == NSControlStateValueOn; //need this since the check box might not exist, and value in prefs might have changed from another creator window
self.fOpenWhenCreated = self.fOpenCheck.state ==
NSControlStateValueOn; //need this since the check box might not exist, and value in prefs might have changed from another creator window
[self.fDefaults setURL:self.fLocation.URLByDeletingLastPathComponent forKey:@"CreatorLocationURL"];
self.window.restorable = NO;
@ -621,7 +625,8 @@ NSMutableSet* creatorWindowControllerSet = nil;
self.fSource.stringValue.UTF8String);
tr_free(trackerInfo);
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(checkProgress) userInfo:nil repeats:YES];
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(checkProgress) userInfo:nil
repeats:YES];
}
- (void)checkProgress
@ -637,7 +642,10 @@ NSMutableSet* creatorWindowControllerSet = nil;
case TrMakemetaResult::OK:
if (self.fOpenWhenCreated)
{
NSDictionary* dict = @{ @"File" : self.fLocation.path, @"Path" : self.fPath.URLByDeletingLastPathComponent.path };
NSDictionary* dict = @{
@"File" : self.fLocation.path,
@"Path" : self.fPath.URLByDeletingLastPathComponent.path
};
[NSNotificationCenter.defaultCenter postNotificationName:@"OpenCreatedTorrentFile" object:self userInfo:dict];
}

View File

@ -94,9 +94,9 @@
NSRect const frame = self.frame;
NSSize const imageSize = self.fBadge.size;
[self.fBadge drawAtPoint:NSMakePoint((NSWidth(frame) - imageSize.width) * 0.5, (NSHeight(frame) - imageSize.height) * 0.5)
fromRect:NSZeroRect
operation:NSCompositingOperationSourceOver
fraction:1.0];
fromRect:NSZeroRect
operation:NSCompositingOperationSourceOver
fraction:1.0];
}
}

View File

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

View File

@ -78,7 +78,8 @@
{
if (!_iconInternal)
{
_iconInternal = [NSWorkspace.sharedWorkspace iconForFileType:_isFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon) : _name.pathExtension];
_iconInternal = [NSWorkspace.sharedWorkspace
iconForFileType:_isFolder ? NSFileTypeForHFSTypeCode(kGenericFolderIcon) : _name.pathExtension];
}
return _iconInternal;
}

View File

@ -85,7 +85,8 @@
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
{
//icon
[self.image drawInRect:[self imageRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0
[self.image drawInRect:[self imageRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositingOperationSourceOver
fraction:1.0
respectFlipped:YES
hints:nil];

View File

@ -185,7 +185,7 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
NSRange const removeRange = NSMakeRange(currentIndex, self.fFileList.count - currentIndex);
[self.fFileList removeObjectsInRange:removeRange];
[self.fOutline removeItemsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:removeRange] inParent:nil
withAnimation:NSTableViewAnimationSlideDown];
withAnimation:NSTableViewAnimationSlideDown];
}
//add new items
@ -282,9 +282,8 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
indexSet = ((FileListNode*)item).indexes;
}
[self.torrent setFileCheckState:[object intValue] != NSControlStateValueOff ? NSControlStateValueOn
: NSControlStateValueOff
forIndexes:indexSet];
[self.torrent setFileCheckState:[object intValue] != NSControlStateValueOff ? NSControlStateValueOn : NSControlStateValueOff
forIndexes:indexSet];
self.fOutline.needsDisplay = YES;
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateUI" object:nil];

View File

@ -156,7 +156,8 @@
imageSize.width,
imageSize.height);
[image drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver 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

@ -385,9 +385,8 @@
if (action == @selector(setGroupFilter:))
{
menuItem.state = menuItem.tag == [NSUserDefaults.standardUserDefaults integerForKey:@"FilterGroup"]
? NSControlStateValueOn
: NSControlStateValueOff;
menuItem.state = menuItem.tag == [NSUserDefaults.standardUserDefaults integerForKey:@"FilterGroup"] ? NSControlStateValueOn :
NSControlStateValueOff;
return YES;
}

View File

@ -237,13 +237,14 @@ GroupsController* fGroupsInstance = nil;
NSInteger const index = candidates.firstIndex;
[self.fGroups addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:@(index),
@"Index",
[NSColor colorWithCalibratedRed:0.0 green:0.65 blue:1.0
alpha:1.0],
@"Color",
@"",
@"Name",
nil]];
@"Index",
[NSColor colorWithCalibratedRed:0.0 green:0.65
blue:1.0
alpha:1.0],
@"Color",
@"",
@"Name",
nil]];
[NSNotificationCenter.defaultCenter postNotificationName:@"UpdateGroups" object:self];
[self saveGroups];

View File

@ -122,9 +122,8 @@
NSInteger globalUseSpeedLimit = torrent.usesGlobalSpeedLimit ? NSControlStateValueOn : NSControlStateValueOff;
while ((torrent = [enumerator nextObject]) &&
(uploadUseSpeedLimit != NSControlStateValueMixed || uploadSpeedLimit != INVALID ||
downloadUseSpeedLimit != NSControlStateValueMixed || downloadSpeedLimit != INVALID ||
globalUseSpeedLimit != NSControlStateValueMixed))
(uploadUseSpeedLimit != NSControlStateValueMixed || uploadSpeedLimit != INVALID || downloadUseSpeedLimit != NSControlStateValueMixed ||
downloadSpeedLimit != INVALID || globalUseSpeedLimit != NSControlStateValueMixed))
{
if (uploadUseSpeedLimit != NSControlStateValueMixed &&
uploadUseSpeedLimit != ([torrent usesSpeedLimit:YES] ? NSControlStateValueOn : NSControlStateValueOff))
@ -195,8 +194,7 @@
NSInteger checkRatio = torrent.ratioSetting;
NSInteger checkIdle = torrent.idleSetting;
NSInteger removeWhenFinishSeeding = torrent.removeWhenFinishSeeding ? NSControlStateValueOn
: NSControlStateValueOff;
NSInteger removeWhenFinishSeeding = torrent.removeWhenFinishSeeding ? NSControlStateValueOn : NSControlStateValueOff;
CGFloat ratioLimit = torrent.ratioLimit;
NSUInteger idleLimit = torrent.idleLimitMinutes;
@ -224,8 +222,7 @@
}
if (removeWhenFinishSeeding != NSControlStateValueMixed &&
removeWhenFinishSeeding != (torrent.removeWhenFinishSeeding ? NSControlStateValueOn
: NSControlStateValueOff))
removeWhenFinishSeeding != (torrent.removeWhenFinishSeeding ? NSControlStateValueOn : NSControlStateValueOff))
{
removeWhenFinishSeeding = NSControlStateValueMixed;
}

View File

@ -15,7 +15,7 @@
#define ANIMATION_ID_KEY @"animationId"
#define WEB_SEED_ANIMATION_ID @"webSeed"
@interface InfoPeersViewController () <CAAnimationDelegate>
@interface InfoPeersViewController ()<CAAnimationDelegate>
@property(nonatomic, copy) NSArray* fTorrents;
@ -71,7 +71,9 @@
[self.fWebSeedTable tableColumnWithIdentifier:@"DL From"].headerCell.stringValue = NSLocalizedString(@"DL", "inspector -> web seed table -> header");
//set table header tool tips
[self.fPeerTable tableColumnWithIdentifier:@"Encryption"].headerToolTip = NSLocalizedString(@"Encrypted Connection", "inspector -> peer table -> header tool tip");
[self.fPeerTable tableColumnWithIdentifier:@"Encryption"].headerToolTip = NSLocalizedString(
@"Encrypted Connection",
"inspector -> peer table -> header tool tip");
[self.fPeerTable tableColumnWithIdentifier:@"Progress"].headerToolTip = NSLocalizedString(@"Available", "inspector -> peer table -> header tool tip");
[self.fPeerTable tableColumnWithIdentifier:@"DL From"].headerToolTip = NSLocalizedString(@"Downloading From Peer", "inspector -> peer table -> header tool tip");
[self.fPeerTable tableColumnWithIdentifier:@"UL To"].headerToolTip = NSLocalizedString(@"Uploading To Peer", "inspector -> peer table -> header tool tip");

View File

@ -51,9 +51,9 @@
- (void)awakeFromNib
{
[self.fTrackerAddRemoveControl.cell setToolTip:NSLocalizedString(@"Add a tracker", "Inspector view -> tracker buttons")
forSegment:TRACKER_ADD_TAG];
forSegment:TRACKER_ADD_TAG];
[self.fTrackerAddRemoveControl.cell setToolTip:NSLocalizedString(@"Remove selected trackers", "Inspector view -> tracker buttons")
forSegment:TRACKER_REMOVE_TAG];
forSegment:TRACKER_REMOVE_TAG];
CGFloat const height = [NSUserDefaults.standardUserDefaults floatForKey:@"InspectorContentHeightTracker"];
if (height != 0.0)
@ -319,7 +319,9 @@
self.fTrackerTable.trackers = self.fTrackers;
[self.fTrackerTable reloadData];
[self.fTrackerTable selectRowIndexes:[NSIndexSet indexSetWithIndex:self.fTrackers.count - 1] byExtendingSelection:NO];
[self.fTrackerTable editColumn:[self.fTrackerTable columnWithIdentifier:@"Tracker"] row:self.fTrackers.count - 1 withEvent:nil select:YES];
[self.fTrackerTable editColumn:[self.fTrackerTable columnWithIdentifier:@"Tracker"] row:self.fTrackers.count - 1
withEvent:nil
select:YES];
}
- (void)removeTrackers

View File

@ -100,24 +100,13 @@ typedef NS_ENUM(unsigned int, tabTag) {
[self.fTabs.cell setToolTip:NSLocalizedString(@"Files", "Inspector -> tab") forSegment:TAB_FILE_TAG];
[self.fTabs.cell setToolTip:NSLocalizedString(@"Options", "Inspector -> tab") forSegment:TAB_OPTIONS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"info.circle"
withFallback:@"InfoGeneral"]
forSegment:TAB_GENERAL_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"square.grid.3x3.fill.square"
withFallback:@"InfoActivity"]
forSegment:TAB_ACTIVITY_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"antenna.radiowaves.left.and.right"
withFallback:@"InfoTracker"]
forSegment:TAB_TRACKERS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"person.2"
withFallback:@"InfoPeers"]
forSegment:TAB_PEERS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"doc.on.doc"
withFallback:@"InfoFiles"]
forSegment:TAB_FILE_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"gearshape"
withFallback:@"InfoOptions"]
forSegment:TAB_OPTIONS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"info.circle" withFallback:@"InfoGeneral"] forSegment:TAB_GENERAL_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"square.grid.3x3.fill.square" withFallback:@"InfoActivity"] forSegment:TAB_ACTIVITY_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"antenna.radiowaves.left.and.right" withFallback:@"InfoTracker"]
forSegment:TAB_TRACKERS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"person.2" withFallback:@"InfoPeers"] forSegment:TAB_PEERS_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"doc.on.doc" withFallback:@"InfoFiles"] forSegment:TAB_FILE_TAG];
[self.fTabs setImage:[NSImage systemSymbol:@"gearshape" withFallback:@"InfoOptions"] forSegment:TAB_OPTIONS_TAG];
//set selected tab
self.fCurrentTabTag = INVALID;
@ -446,7 +435,7 @@ typedef NS_ENUM(unsigned int, tabTag) {
self.fImageView.image = [NSImage imageNamed:NSImageNameMultipleDocuments];
self.fNameField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ Torrents Selected", "Inspector -> selected torrents"),
[NSString formattedUInteger:numberSelected]];
[NSString formattedUInteger:numberSelected]];
self.fNameField.hidden = NO;
uint64_t size = 0;

View File

@ -105,8 +105,9 @@
filterButtonFrame.origin.x -= NSWidth(clearButtonFrame) - oldClearButtonWidth;
self.fFilterField.frame = filterButtonFrame;
self.fAttributes = [[[self.fMessageTable tableColumnWithIdentifier:@"Message"].dataCell attributedStringValue] attributesAtIndex:0
effectiveRange:NULL];
self.fAttributes = [[[self.fMessageTable tableColumnWithIdentifier:@"Message"].dataCell attributedStringValue]
attributesAtIndex:0
effectiveRange:NULL];
//select proper level in popup button
switch ([NSUserDefaults.standardUserDefaults integerForKey:@"MessageLevel"])
@ -147,8 +148,9 @@
{
if (!self.fTimer)
{
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_SECONDS target:self selector:@selector(updateLog:) userInfo:nil
repeats:YES];
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_SECONDS target:self selector:@selector(updateLog:)
userInfo:nil
repeats:YES];
[self updateLog:nil];
}
}
@ -173,7 +175,7 @@
{
[self.fTimer invalidate];
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_SECONDS target:self selector:@selector(updateLog:) userInfo:nil
repeats:YES];
repeats:YES];
[self updateLog:nil];
}
@ -406,7 +408,7 @@
[self.fMessageTable beginUpdates];
[self.fMessageTable removeRowsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.fDisplayedMessages.count)]
withAnimation:NSTableViewAnimationSlideLeft];
withAnimation:NSTableViewAnimationSlideLeft];
[self.fDisplayedMessages removeAllObjects];
@ -460,7 +462,8 @@
- (void)resizeColumn
{
[self.fMessageTable noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.fMessageTable.numberOfRows)]];
[self.fMessageTable
noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.fMessageTable.numberOfRows)]];
}
- (BOOL)shouldIncludeMessageForFilter:(NSString*)filterString message:(NSDictionary*)message
@ -481,10 +484,10 @@
NSString* filterString = self.fFilterField.stringValue;
NSIndexSet* indexes = [self.fMessages indexesOfObjectsWithOptions:NSEnumerationConcurrent
passingTest:^BOOL(id message, NSUInteger idx, BOOL* stop) {
return [((NSDictionary*)message)[@"Level"] integerValue] <= level &&
[self shouldIncludeMessageForFilter:filterString message:message];
}];
passingTest:^BOOL(id message, NSUInteger idx, BOOL* stop) {
return [((NSDictionary*)message)[@"Level"] integerValue] <= level &&
[self shouldIncludeMessageForFilter:filterString message:message];
}];
NSArray* tempMessages = [[self.fMessages objectsAtIndexes:indexes] sortedArrayUsingDescriptors:self.fMessageTable.sortDescriptors];
@ -524,7 +527,7 @@
NSRange const removeRange = NSMakeRange(currentIndex, self.fDisplayedMessages.count - currentIndex);
[self.fDisplayedMessages removeObjectsInRange:removeRange];
[self.fMessageTable removeRowsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:removeRange]
withAnimation:NSTableViewAnimationSlideDown];
withAnimation:NSTableViewAnimationSlideDown];
}
//add new items

View File

@ -59,7 +59,8 @@
imageSize.width,
imageSize.height);
[checkImage drawInRect:rect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES
[checkImage drawInRect:rect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0
respectFlipped:YES
hints:nil];
}
}

View File

@ -34,8 +34,8 @@
_fStatus = PORT_STATUS_CHECKING;
_fTimer = [NSTimer scheduledTimerWithTimeInterval:CHECK_FIRE target:self selector:@selector(startProbe:)
userInfo:@(portNumber)
repeats:NO];
userInfo:@(portNumber)
repeats:NO];
if (!delay)
{
[_fTimer fire];

View File

@ -237,8 +237,9 @@
self.fNatStatus = -1;
[self updatePortStatus];
self.fPortStatusTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(updatePortStatus) userInfo:nil
repeats:YES];
self.fPortStatusTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(updatePortStatus)
userInfo:nil
repeats:YES];
//set peer connections
self.fPeersGlobalField.intValue = [self.fDefaults integerForKey:@"PeersTotal"];
@ -789,7 +790,7 @@
- (void)setSpeedLimit:(id)sender
{
[self.fDefaults setInteger:[sender intValue]
forKey:sender == self.fSpeedLimitUploadField ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"];
forKey:sender == self.fSpeedLimitUploadField ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"];
[self applyAltSpeedSettings];
}

View File

@ -83,8 +83,9 @@ OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview,
NSString* fileSizeString = [NSString stringForFileSize:metainfo.totalSize()];
if (is_multifile)
{
NSString* fileCountString = [NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"%@ files", nil, bundle, "quicklook file count"),
[NSString formattedUInteger:n_files]];
NSString* fileCountString = [NSString
stringWithFormat:NSLocalizedStringFromTableInBundle(@"%@ files", nil, bundle, "quicklook file count"),
[NSString formattedUInteger:n_files]];
fileSizeString = [NSString stringWithFormat:@"%@, %@", fileCountString, fileSizeString];
}
[htmlString appendFormat:@"<p>%@</p>", fileSizeString];
@ -184,8 +185,9 @@ OSStatus GeneratePreviewForURL(void* thisInterface, QLPreviewRequestRef preview,
NSMutableString* listSection = [NSMutableString string];
[listSection appendString:@"<table>"];
NSString* fileTitleString = [NSString stringWithFormat:NSLocalizedStringFromTableInBundle(@"%@ Files", nil, bundle, "quicklook file header"),
[NSString formattedUInteger:n_files]];
NSString* fileTitleString = [NSString
stringWithFormat:NSLocalizedStringFromTableInBundle(@"%@ Files", nil, bundle, "quicklook file header"),
[NSString formattedUInteger:n_files]];
[listSection appendFormat:@"<tr><th>%@</th></tr>", fileTitleString];
#warning display size?

View File

@ -60,8 +60,9 @@ tr_session* fLib = NULL;
{
[self updateStats];
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_SECONDS target:self selector:@selector(updateStats) userInfo:nil
repeats:YES];
self.fTimer = [NSTimer scheduledTimerWithTimeInterval:UPDATE_SECONDS target:self selector:@selector(updateStats)
userInfo:nil
repeats:YES];
[NSRunLoop.currentRunLoop addTimer:self.fTimer forMode:NSModalPanelRunLoopMode];
[NSRunLoop.currentRunLoop addTimer:self.fTimer forMode:NSEventTrackingRunLoopMode];
@ -79,7 +80,13 @@ tr_session* fLib = NULL;
//size of all labels
CGFloat const oldWidth = self.fUploadedLabelField.frame.size.width;
NSArray* labels = @[ self.fUploadedLabelField, self.fDownloadedLabelField, self.fRatioLabelField, self.fTimeLabelField, self.fNumOpenedLabelField ];
NSArray* labels = @[
self.fUploadedLabelField,
self.fDownloadedLabelField,
self.fRatioLabelField,
self.fTimeLabelField,
self.fNumOpenedLabelField
];
CGFloat maxWidth = CGFLOAT_MIN;
for (NSTextField* label in labels)
@ -211,7 +218,7 @@ tr_session* fLib = NULL;
self.fTimeField.stringValue = [timeFormatter stringFromTimeInterval:statsSession.secondsActive];
self.fTimeAllField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ total", "stats total"),
[timeFormatter stringFromTimeInterval:statsAll.secondsActive]];
[timeFormatter stringFromTimeInterval:statsAll.secondsActive]];
if (statsAll.sessionCount == 1)
{
@ -220,7 +227,7 @@ tr_session* fLib = NULL;
else
{
self.fNumOpenedField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ times", "stats window -> times opened"),
[NSString formattedUInteger:statsAll.sessionCount]];
[NSString formattedUInteger:statsAll.sessionCount]];
}
}

View File

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

View File

@ -199,7 +199,7 @@ bool trashDataFile(char const* filename, tr_error** error)
{
//restore GroupValue
torrent.groupValue = [history[@"GroupValue"] intValue];
//start transfer
NSNumber* active;
if (!pause && (active = history[@"Active"]) && active.boolValue)
@ -1873,7 +1873,11 @@ bool trashDataFile(char const* filename, tr_error** error)
tempNode = [[FileListNode alloc] initWithFolderName:pathComponents[0] path:@"" torrent:self];
}
[self insertPathForComponents:pathComponents withComponentIndex:1 forParent:tempNode fileSize:file.length index:i
[self insertPathForComponents:pathComponents
withComponentIndex:1
forParent:tempNode
fileSize:file.length
index:i
flatList:flatFileList];
}

View File

@ -186,10 +186,8 @@
{
[NSApp sendEvent:event];
}
event = [controlView.window nextEventMatchingMask:(NSEventMaskLeftMouseUp |
NSEventMaskLeftMouseDragged |
NSEventMaskMouseEntered |
NSEventMaskMouseExited)];
event = [controlView.window nextEventMatchingMask:(NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged |
NSEventMaskMouseEntered | NSEventMaskMouseExited)];
}
self.fTracking = NO;
@ -332,7 +330,8 @@
if (!minimal || !(!self.fTracking && self.hoverAction)) //don't show in minimal mode when hovered over
{
NSImage* icon = (minimal && error) ? [NSImage imageNamed:NSImageNameCaution] : torrent.icon;
[icon drawInRect:iconRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES hints:nil];
[icon drawInRect:iconRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES
hints:nil];
}
//error badge
@ -340,7 +339,8 @@
{
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:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES
[errorImage drawInRect:errorRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0
respectFlipped:YES
hints:nil];
}
@ -422,7 +422,8 @@
}
NSRect const controlRect = [self controlButtonRectForBounds:cellFrame];
[controlImage drawInRect:controlRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES
[controlImage drawInRect:controlRect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0
respectFlipped:YES
hints:nil];
minimalTitleRightBound = MIN(minimalTitleRightBound, NSMinX(controlRect));
@ -442,7 +443,8 @@
}
NSImage* revealImage = [NSImage imageNamed:revealImageString];
[revealImage drawInRect:[self revealButtonRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositingOperationSourceOver
[revealImage drawInRect:[self revealButtonRectForBounds:cellFrame] fromRect:NSZeroRect
operation:NSCompositingOperationSourceOver
fraction:1.0
respectFlipped:YES
hints:nil];
@ -489,8 +491,7 @@
PRIORITY_ICON_WIDTH,
PRIORITY_ICON_HEIGHT);
NSColor* priorityColor = self.backgroundStyle == NSBackgroundStyleEmphasized ? 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];

View File

@ -455,7 +455,8 @@
return;
}
BOOL const pushed = row != -1 && (self.actionButtonHoverRow == row || self.revealButtonHoverRow == row || self.controlButtonHoverRow == row);
BOOL const pushed = row != -1 &&
(self.actionButtonHoverRow == row || self.revealButtonHoverRow == row || self.controlButtonHoverRow == row);
//if pushing a button, don't change the selected rows
if (pushed)
@ -601,9 +602,7 @@
{
unichar const firstChar = [event.charactersIgnoringModifiers characterAtIndex:0];
if (firstChar == 'f' &&
event.modifierFlags & NSEventModifierFlagOption &&
event.modifierFlags & NSEventModifierFlagCommand)
if (firstChar == 'f' && event.modifierFlags & NSEventModifierFlagOption && event.modifierFlags & NSEventModifierFlagCommand)
{
[self.fController focusFilterField];
}

View File

@ -197,11 +197,12 @@ NSMutableSet* fTrackerIconLoading;
return icon;
}
if (@available(macOS 11.0, *)) {
if (@available(macOS 11.0, *))
{
NSImage* result = [NSImage imageWithSystemSymbolName:@"globe" accessibilityDescription:nil];
[result lockFocus];
[NSColor.textColor set];
NSRect imageRect = {NSZeroPoint, [result size]};
NSRect imageRect = { NSZeroPoint, [result size] };
NSRectFillUsingOperation(imageRect, NSCompositingOperationSourceIn);
[result unlockFocus];
return result;

View File

@ -140,7 +140,8 @@
}
else
{
peerString = [NSString stringWithFormat:NSLocalizedString(@"got %d peers", "Tracker last announce"), self.fStat.lastAnnouncePeerCount];
peerString = [NSString stringWithFormat:NSLocalizedString(@"got %d peers", "Tracker last announce"),
self.fStat.lastAnnouncePeerCount];
}
baseString = [baseString stringByAppendingFormat:@" (%@)", peerString];
}
@ -177,7 +178,7 @@
case TR_TRACKER_INACTIVE:
return self.fStat.isBackup ? NSLocalizedString(@"Tracker will be used as a backup", "Tracker next announce") :
NSLocalizedString(@"Announce not scheduled", "Tracker next announce");
NSLocalizedString(@"Announce not scheduled", "Tracker next announce");
default:
NSAssert1(NO, @"unknown announce state: %d", self.fStat.announceState);