diff --git a/macosx/Controller.m b/macosx/Controller.m index 99b17772c..e3c7679f7 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -3760,10 +3760,7 @@ static void removeKeRangerRansomware() [segmentedControl setCell: [[ToolbarSegmentedCell alloc] init]]; [groupItem setView: segmentedControl]; NSSegmentedCell * segmentedCell = (NSSegmentedCell *)[segmentedControl cell]; - - if ([NSApp isOnYosemiteOrBetter]) { - segmentedControl.segmentStyle = NSSegmentStyleSeparated; - } + segmentedControl.segmentStyle = NSSegmentStyleSeparated; [segmentedControl setSegmentCount: 2]; [segmentedCell setTrackingMode: NSSegmentSwitchTrackingMomentary]; @@ -3818,10 +3815,7 @@ static void removeKeRangerRansomware() [segmentedControl setCell: [[ToolbarSegmentedCell alloc] init]]; [groupItem setView: segmentedControl]; NSSegmentedCell * segmentedCell = (NSSegmentedCell *)[segmentedControl cell]; - - if ([NSApp isOnYosemiteOrBetter]) { - segmentedControl.segmentStyle = NSSegmentStyleSeparated; - } + segmentedControl.segmentStyle = NSSegmentStyleSeparated; [segmentedControl setSegmentCount: 2]; [segmentedCell setTrackingMode: NSSegmentSwitchTrackingMomentary]; diff --git a/macosx/FilterBarView.m b/macosx/FilterBarView.m index 0bfda1e03..6d6aca727 100644 --- a/macosx/FilterBarView.m +++ b/macosx/FilterBarView.m @@ -25,20 +25,6 @@ @implementation FilterBarView -- (id) initWithFrame: (NSRect) rect -{ - if ((self = [super initWithFrame: rect])) - { - if (![NSApp isOnYosemiteOrBetter]) { - NSColor * lightColor = [NSColor colorWithCalibratedRed: 235.0/255.0 green: 235.0/255.0 blue: 235.0/255.0 alpha: 1.0]; - NSColor * darkColor = [NSColor colorWithCalibratedRed: 205.0/255.0 green: 205.0/255.0 blue: 205.0/255.0 alpha: 1.0]; - fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor]; - } - } - return self; -} - - - (BOOL) mouseDownCanMoveWindow { return NO; @@ -51,50 +37,14 @@ - (void) drawRect: (NSRect) rect { - if ([NSApp isOnYosemiteOrBetter]) { - [[NSColor windowBackgroundColor] setFill]; - NSRectFill(rect); - - const NSRect lineBorderRect = NSMakeRect(NSMinX(rect), 0.0, NSWidth(rect), 1.0); - if (NSIntersectsRect(lineBorderRect, rect)) - { - [[NSColor gridColor] setFill]; - NSRectFill(lineBorderRect); - } - } - else { - NSInteger count = 0; - NSRect gridRects[2]; - NSColor * colorRects[2]; - - NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0); - if (NSIntersectsRect(lineBorderRect, rect)) - { - gridRects[count] = lineBorderRect; - colorRects[count] = [NSColor whiteColor]; - ++count; - - rect.size.height -= 1.0; - } - - lineBorderRect.origin.y = 0.0; - if (NSIntersectsRect(lineBorderRect, rect)) - { - gridRects[count] = lineBorderRect; - colorRects[count] = [NSColor colorWithCalibratedWhite: 0.65 alpha: 1.0]; - ++count; - - rect.origin.y += 1.0; - rect.size.height -= 1.0; - } - - if (!NSIsEmptyRect(rect)) - { - const NSRect gradientRect = NSMakeRect(NSMinX(rect), 1.0, NSWidth(rect), NSHeight([self bounds]) - 1.0 - 1.0); //proper gradient requires the full height of the bar - [fGradient drawInRect: gradientRect angle: 270.0]; - } - - NSRectFillListWithColors(gridRects, colorRects, count); + [[NSColor windowBackgroundColor] setFill]; + NSRectFill(rect); + + const NSRect lineBorderRect = NSMakeRect(NSMinX(rect), 0.0, NSWidth(rect), 1.0); + if (NSIntersectsRect(lineBorderRect, rect)) + { + [[NSColor gridColor] setFill]; + NSRectFill(lineBorderRect); } } diff --git a/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/Contents.json b/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/Contents.json deleted file mode 100644 index 61ef1c9a2..000000000 --- a/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "filename" : "PurpleDotGlossy.png", - "scale" : "1x" - }, - { - "idiom" : "mac", - "filename" : "PurpleDotGlossy@2x.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "original" - } -} \ No newline at end of file diff --git a/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/PurpleDotGlossy.png b/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/PurpleDotGlossy.png deleted file mode 100644 index 58deefaae..000000000 Binary files a/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/PurpleDotGlossy.png and /dev/null differ diff --git a/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/PurpleDotGlossy@2x.png b/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/PurpleDotGlossy@2x.png deleted file mode 100644 index e5035a39c..000000000 Binary files a/macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/PurpleDotGlossy@2x.png and /dev/null differ diff --git a/macosx/Images/Images.xcassets/RedDotGlossy.imageset/Contents.json b/macosx/Images/Images.xcassets/RedDotGlossy.imageset/Contents.json deleted file mode 100644 index 2e6d3437a..000000000 --- a/macosx/Images/Images.xcassets/RedDotGlossy.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "filename" : "RedDotGlossy.png", - "scale" : "1x" - }, - { - "idiom" : "mac", - "filename" : "RedDotGlossy@2x.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "original" - } -} \ No newline at end of file diff --git a/macosx/Images/Images.xcassets/RedDotGlossy.imageset/RedDotGlossy.png b/macosx/Images/Images.xcassets/RedDotGlossy.imageset/RedDotGlossy.png deleted file mode 100644 index 44b63a5c5..000000000 Binary files a/macosx/Images/Images.xcassets/RedDotGlossy.imageset/RedDotGlossy.png and /dev/null differ diff --git a/macosx/Images/Images.xcassets/RedDotGlossy.imageset/RedDotGlossy@2x.png b/macosx/Images/Images.xcassets/RedDotGlossy.imageset/RedDotGlossy@2x.png deleted file mode 100644 index 1e30550a4..000000000 Binary files a/macosx/Images/Images.xcassets/RedDotGlossy.imageset/RedDotGlossy@2x.png and /dev/null differ diff --git a/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/Contents.json b/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/Contents.json deleted file mode 100644 index fff427d6f..000000000 --- a/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "filename" : "YellowDotGlossy.png", - "scale" : "1x" - }, - { - "idiom" : "mac", - "filename" : "YellowDotGlossy@2x.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "original" - } -} \ No newline at end of file diff --git a/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/YellowDotGlossy.png b/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/YellowDotGlossy.png deleted file mode 100644 index 6e46203a1..000000000 Binary files a/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/YellowDotGlossy.png and /dev/null differ diff --git a/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/YellowDotGlossy@2x.png b/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/YellowDotGlossy@2x.png deleted file mode 100644 index 902b5f56a..000000000 Binary files a/macosx/Images/Images.xcassets/YellowDotGlossy.imageset/YellowDotGlossy@2x.png and /dev/null differ diff --git a/macosx/InfoActivityViewController.m b/macosx/InfoActivityViewController.m index 0bf6b54b0..3fbcc12eb 100644 --- a/macosx/InfoActivityViewController.m +++ b/macosx/InfoActivityViewController.m @@ -178,25 +178,19 @@ //uses a relative date, so can't be set once [fDateAddedField setObjectValue: [torrent dateAdded]]; - - if ([NSApp isOnYosemiteOrBetter]) { - static NSDateComponentsFormatter *timeFormatter; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - timeFormatter = [NSDateComponentsFormatter new]; - timeFormatter.unitsStyle = NSDateComponentsFormatterUnitsStyleShort; - timeFormatter.allowedUnits = NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; - timeFormatter.zeroFormattingBehavior = NSDateComponentsFormatterZeroFormattingBehaviorDropLeading; - }); - - [fDownloadTimeField setStringValue: [timeFormatter stringFromTimeInterval:[torrent secondsDownloading]]]; - [fSeedTimeField setStringValue: [timeFormatter stringFromTimeInterval:[torrent secondsSeeding]]]; - } - else { - [fDownloadTimeField setStringValue: [NSString timeString: [torrent secondsDownloading] includesTimeRemainingPhrase:NO showSeconds: YES]]; - [fSeedTimeField setStringValue: [NSString timeString: [torrent secondsSeeding] includesTimeRemainingPhrase:NO showSeconds: YES]]; - } - + + static NSDateComponentsFormatter *timeFormatter; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + timeFormatter = [NSDateComponentsFormatter new]; + timeFormatter.unitsStyle = NSDateComponentsFormatterUnitsStyleShort; + timeFormatter.allowedUnits = NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; + timeFormatter.zeroFormattingBehavior = NSDateComponentsFormatterZeroFormattingBehaviorDropLeading; + }); + + [fDownloadTimeField setStringValue: [timeFormatter stringFromTimeInterval:[torrent secondsDownloading]]]; + [fSeedTimeField setStringValue: [timeFormatter stringFromTimeInterval:[torrent secondsSeeding]]]; + [fPiecesView updateView]; } else if (numberSelected > 1) diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index 5c00c8e7d..d43070760 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -69,12 +69,6 @@ [[fLevelButton itemAtIndex: LEVEL_ERROR] setTitle: NSLocalizedString(@"Error", "Message window -> level string")]; [[fLevelButton itemAtIndex: LEVEL_INFO] setTitle: NSLocalizedString(@"Info", "Message window -> level string")]; [[fLevelButton itemAtIndex: LEVEL_DEBUG] setTitle: NSLocalizedString(@"Debug", "Message window -> level string")]; - if (![NSApp isOnYosemiteOrBetter]) - { - [[fLevelButton itemAtIndex: LEVEL_ERROR] setImage: [NSImage imageNamed: @"RedDotGlossy"]]; - [[fLevelButton itemAtIndex: LEVEL_INFO] setImage: [NSImage imageNamed: @"YellowDotGlossy"]]; - [[fLevelButton itemAtIndex: LEVEL_DEBUG] setImage: [NSImage imageNamed: @"PurpleDotGlossy"]]; - } const CGFloat levelButtonOldWidth = NSWidth([fLevelButton frame]); [fLevelButton sizeToFit]; @@ -261,11 +255,11 @@ switch (level) { case TR_LOG_ERROR: - return [NSImage imageNamed: ([NSApp isOnYosemiteOrBetter] ? @"RedDotFlat" : @"RedDotGlossy")]; + return [NSImage imageNamed: @"RedDotFlat"]; case TR_LOG_INFO: - return [NSImage imageNamed: ([NSApp isOnYosemiteOrBetter] ? @"YellowDotFlat" : @"YellowDotGlossy")]; + return [NSImage imageNamed: @"YellowDotFlat"]; case TR_LOG_DEBUG: - return [NSImage imageNamed: ([NSApp isOnYosemiteOrBetter] ? @"PurpleDotFlat" : @"PurpleDotGlossy")]; + return [NSImage imageNamed: @"PurpleDotFlat"]; default: NSAssert1(NO, @"Unknown message log level: %ld", level); return nil; diff --git a/macosx/NSApplicationAdditions.h b/macosx/NSApplicationAdditions.h index ae735e9c7..eb35935d5 100644 --- a/macosx/NSApplicationAdditions.h +++ b/macosx/NSApplicationAdditions.h @@ -24,7 +24,6 @@ @interface NSApplication (NSApplicationAdditions) -- (BOOL) isOnYosemiteOrBetter; - (BOOL) isOnMojaveOrBetter; - (BOOL) isDarkMode; diff --git a/macosx/NSApplicationAdditions.m b/macosx/NSApplicationAdditions.m index 53c35e67a..a4dfe899c 100644 --- a/macosx/NSApplicationAdditions.m +++ b/macosx/NSApplicationAdditions.m @@ -24,11 +24,6 @@ @implementation NSApplication (NSApplicationAdditions) -- (BOOL) isOnYosemiteOrBetter -{ - return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9; -} - - (BOOL) isOnMojaveOrBetter { return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_13; diff --git a/macosx/NSStringAdditions.h b/macosx/NSStringAdditions.h index e3d931ce0..a69faae22 100644 --- a/macosx/NSStringAdditions.h +++ b/macosx/NSStringAdditions.h @@ -38,9 +38,6 @@ + (NSString *) percentString: (CGFloat) progress longDecimals: (BOOL) longDecimals; -+ (NSString *) timeString: (uint64_t) seconds includesTimeRemainingPhrase: (BOOL) includesTimeRemainingPhrase showSeconds: (BOOL) showSeconds; -+ (NSString *) timeString: (uint64_t) seconds includesTimeRemainingPhrase: (BOOL) includesTimeRemainingPhrase showSeconds: (BOOL) showSeconds maxFields: (NSUInteger) max; - - (NSComparisonResult) compareNumeric: (NSString *) string; //simple compare method for strings with numbers (works for IP addresses) - (NSArray *) betterComponentsSeparatedByCharactersInSet: (NSCharacterSet *) separators; //like componentsSeparatedByCharactersInSet:, but excludes blank values diff --git a/macosx/NSStringAdditions.m b/macosx/NSStringAdditions.m index 95b5d1118..480afe9d5 100644 --- a/macosx/NSStringAdditions.m +++ b/macosx/NSStringAdditions.m @@ -124,66 +124,6 @@ return [NSString localizedStringWithFormat: @"%.1f%%", tr_truncd(progress * 100.0, 1)]; } -+ (NSString *) timeString: (uint64_t) seconds includesTimeRemainingPhrase: (BOOL) includesTimeRemainingPhrase showSeconds: (BOOL) showSeconds -{ - return [NSString timeString: seconds - includesTimeRemainingPhrase: includesTimeRemainingPhrase - showSeconds: showSeconds - maxFields: NSUIntegerMax]; -} - -+ (NSString *) timeString: (uint64_t) seconds includesTimeRemainingPhrase: (BOOL) includesTimeRemainingPhrase showSeconds: (BOOL) showSeconds maxFields: (NSUInteger) max -{ - NSAssert(![NSApp isOnYosemiteOrBetter], @"you should be using NSDateComponentsFormatter on >= 10.10"); - NSParameterAssert(max > 0); - - NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: MIN(max, 5u)]; - NSUInteger remaining = seconds; //causes problems for some users when it's a uint64_t - - if (seconds >= 31557600) //official amount of seconds in one year - { - const NSUInteger years = remaining / 31557600; - if (years == 1) - [timeArray addObject: NSLocalizedString(@"1 year", "time string")]; - else - [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u years", "time string"), years]]; - remaining %= 31557600; - --max; - } - if (max > 0 && seconds >= (24 * 60 * 60)) - { - const NSUInteger days = remaining / (24 * 60 * 60); - if (days == 1) - [timeArray addObject: NSLocalizedString(@"1 day", "time string")]; - else - [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u days", "time string"), days]]; - remaining %= (24 * 60 * 60); - --max; - } - if (max > 0 && seconds >= (60 * 60)) - { - [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u hr", "time string"), remaining / (60 * 60)]]; - remaining %= (60 * 60); - --max; - } - if (max > 0 && (!showSeconds || seconds >= 60)) - { - [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u min", "time string"), remaining / 60]]; - remaining %= 60; - --max; - } - if (max > 0 && showSeconds) - [timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%u sec", "time string"), remaining]]; - - NSString * timeString = [timeArray componentsJoinedByString: @" "]; - - if (includesTimeRemainingPhrase) { - timeString = [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "time remaining string"), timeString]; - } - - return timeString; -} - - (NSComparisonResult) compareNumeric: (NSString *) string { const NSStringCompareOptions comparisonOptions = NSNumericSearch | NSForcedOrderingSearch; diff --git a/macosx/StatsWindowController.m b/macosx/StatsWindowController.m index 42c93d0c2..fd304cd2b 100644 --- a/macosx/StatsWindowController.m +++ b/macosx/StatsWindowController.m @@ -188,27 +188,21 @@ tr_session * fLib = NULL; NSString * totalRatioString = statsAll.ratio != TR_RATIO_NA ? [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString stringForRatio: statsAll.ratio]] - : NSLocalizedString(@"Total N/A", "stats total"); + : NSLocalizedString(@"Total N/A", "stats total"); [fRatioAllField setStringValue: totalRatioString]; - - if ([NSApp isOnYosemiteOrBetter]) { - static NSDateComponentsFormatter *timeFormatter; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - timeFormatter = [NSDateComponentsFormatter new]; - timeFormatter.unitsStyle = NSDateComponentsFormatterUnitsStyleFull; - timeFormatter.maximumUnitCount = 3; - timeFormatter.allowedUnits = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekOfMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute; - }); - - [fTimeField setStringValue: [timeFormatter stringFromTimeInterval:statsSession.secondsActive]]; - [fTimeAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [timeFormatter stringFromTimeInterval:statsAll.secondsActive]]]; - } - else { - [fTimeField setStringValue: [NSString timeString: statsSession.secondsActive includesTimeRemainingPhrase:NO showSeconds: NO]]; - [fTimeAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString timeString: statsAll.secondsActive includesTimeRemainingPhrase:NO showSeconds: NO]]]; - } - + + static NSDateComponentsFormatter *timeFormatter; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + timeFormatter = [NSDateComponentsFormatter new]; + timeFormatter.unitsStyle = NSDateComponentsFormatterUnitsStyleFull; + timeFormatter.maximumUnitCount = 3; + timeFormatter.allowedUnits = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekOfMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute; + }); + + [fTimeField setStringValue: [timeFormatter stringFromTimeInterval:statsSession.secondsActive]]; + [fTimeAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [timeFormatter stringFromTimeInterval:statsAll.secondsActive]]]; + if (statsAll.sessionCount == 1) [fNumOpenedField setStringValue: NSLocalizedString(@"1 time", "stats window -> times opened")]; else diff --git a/macosx/StatusBarView.m b/macosx/StatusBarView.m index ce890486c..251605d50 100644 --- a/macosx/StatusBarView.m +++ b/macosx/StatusBarView.m @@ -40,24 +40,19 @@ NSColor * lightColor = [NSColor colorWithCalibratedRed: 160.0/255.0 green: 160.0/255.0 blue: 160.0/255.0 alpha: 1.0]; NSColor * darkColor = [NSColor colorWithCalibratedRed: 155.0/255.0 green: 155.0/255.0 blue: 155.0/255.0 alpha: 1.0]; fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor]; - - if (![NSApp isOnYosemiteOrBetter]) - { - CIFilter * randomFilter = [CIFilter filterWithName: @"CIRandomGenerator"]; - [randomFilter setDefaults]; - - fNoiseImage = [randomFilter valueForKey: @"outputImage"]; - - CIFilter * monochromeFilter = [CIFilter filterWithName: @"CIColorMonochrome"]; - [monochromeFilter setDefaults]; - [monochromeFilter setValue: fNoiseImage forKey: @"inputImage"]; - CIColor * monoFilterColor = [CIColor colorWithRed: 1.0 green: 1.0 blue: 1.0]; - [monochromeFilter setValue: monoFilterColor forKey: @"inputColor"]; - fNoiseImage = [monochromeFilter valueForKey:@"outputImage"]; - } - else - fNoiseImage = nil; - + + CIFilter * randomFilter = [CIFilter filterWithName: @"CIRandomGenerator"]; + [randomFilter setDefaults]; + + fNoiseImage = [randomFilter valueForKey: @"outputImage"]; + + CIFilter * monochromeFilter = [CIFilter filterWithName: @"CIColorMonochrome"]; + [monochromeFilter setDefaults]; + [monochromeFilter setValue: fNoiseImage forKey: @"inputImage"]; + CIColor * monoFilterColor = [CIColor colorWithRed: 1.0 green: 1.0 blue: 1.0]; + [monochromeFilter setValue: monoFilterColor forKey: @"inputColor"]; + fNoiseImage = [monochromeFilter valueForKey:@"outputImage"]; + [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reload) name: NSWindowDidBecomeMainNotification object: [self window]]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reload) name: NSWindowDidResignMainNotification object: [self window]]; } @@ -81,77 +76,14 @@ - (void) drawRect: (NSRect) rect { - if ([NSApp isOnYosemiteOrBetter]) { - [[NSColor windowBackgroundColor] setFill]; - NSRectFill(rect); - - const NSRect lineBorderRect = NSMakeRect(NSMinX(rect), 0.0, NSWidth(rect), 1.0); - if (NSIntersectsRect(lineBorderRect, rect)) - { - [[NSColor gridColor] setFill]; - NSRectFill(lineBorderRect); - } - } - else { - const BOOL active = [[self window] isMainWindow]; - - NSInteger count = 0; - NSRect gridRects[active ? 2 : 3]; - NSColor * colorRects[active ? 2 : 3]; - - //bottom line - NSRect lineBorderRect = NSMakeRect(NSMinX(rect), 0.0, NSWidth(rect), 1.0); - NSRect intersectLineBorderRect = NSIntersectionRect(lineBorderRect, rect); - if (!NSIsEmptyRect(intersectLineBorderRect)) - { - gridRects[count] = intersectLineBorderRect; - colorRects[count] = active ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0] - : [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0]; - ++count; - - rect.origin.y += intersectLineBorderRect.size.height; - rect.size.height -= intersectLineBorderRect.size.height; - } - - - //top line - if (active) - { - lineBorderRect.origin.y = NSHeight([self bounds]) - 1.0; - intersectLineBorderRect = NSIntersectionRect(lineBorderRect, rect); - if (!NSIsEmptyRect(intersectLineBorderRect)) - { - gridRects[count] = intersectLineBorderRect; - colorRects[count] = [NSColor colorWithCalibratedWhite: 0.75 alpha: 1.0]; - ++count; - - rect.size.height -= intersectLineBorderRect.size.height; - } - } - - if (!NSIsEmptyRect(rect)) - { - if (active) - { - const NSRect gradientRect = NSMakeRect(NSMinX(rect), 1.0, NSWidth(rect), NSHeight([self bounds]) - 1.0 - 1.0); //proper gradient requires the full height of the bar - [fGradient drawInRect: gradientRect angle: 270.0]; - } - else - { - gridRects[count] = rect; - colorRects[count] = [NSColor colorWithCalibratedWhite: 0.85 alpha: 1.0]; - ++count; - } - } - - NSRectFillListWithColors(gridRects, colorRects, count); - - if (fNoiseImage) { - [fNoiseImage drawInRect: rect - fromRect: [self convertRectToBacking: rect] - operation: NSCompositeSourceOver - fraction: 0.12]; - } + [[NSColor windowBackgroundColor] setFill]; + NSRectFill(rect); + + const NSRect lineBorderRect = NSMakeRect(NSMinX(rect), 0.0, NSWidth(rect), 1.0); + if (NSIntersectsRect(lineBorderRect, rect)) + { + [[NSColor gridColor] setFill]; + NSRectFill(lineBorderRect); } } diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 83db10b5a..ba534f457 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -1841,26 +1841,11 @@ bool trashDataFile(const char * filename, tr_error ** error) //quarantine the finished data NSString * dataLocation = [[self currentDirectory] stringByAppendingPathComponent: [self name]]; + NSURL * dataLocationUrl = [NSURL fileURLWithPath: dataLocation]; NSDictionary * quarantineProperties = @{ (NSString *)kLSQuarantineTypeKey : (NSString *)kLSQuarantineTypeOtherDownload }; - if ([NSApp isOnYosemiteOrBetter]) - { - NSURL * dataLocationUrl = [NSURL fileURLWithPath: dataLocation]; - NSError * error = nil; - if (![dataLocationUrl setResourceValue: quarantineProperties forKey: NSURLQuarantinePropertiesKey error: &error]) - NSLog(@"Failed to quarantine %@: %@", dataLocation, [error description]); - } - else - { - NSString * dataLocation = [[self currentDirectory] stringByAppendingPathComponent: [self name]]; - FSRef ref; - if (FSPathMakeRef((const UInt8 *)[dataLocation UTF8String], &ref, NULL) == noErr) - { - if (LSSetItemAttribute(&ref, kLSRolesAll, kLSItemQuarantineProperties, (__bridge CFTypeRef)(quarantineProperties)) != noErr) - NSLog(@"Failed to quarantine: %@", dataLocation); - } - else - NSLog(@"Could not find file to quarantine: %@", dataLocation); - } + NSError * error = nil; + if (![dataLocationUrl setResourceValue: quarantineProperties forKey: NSURLQuarantinePropertiesKey error: &error]) + NSLog(@"Failed to quarantine %@: %@", dataLocation, [error description]); break; } case TR_LEECH: @@ -1991,25 +1976,17 @@ bool trashDataFile(const char * filename, tr_error ** error) else return NSLocalizedString(@"remaining time unknown", "Torrent -> eta string"); - NSString * idleString; - - if ([NSApp isOnYosemiteOrBetter]) { - static NSDateComponentsFormatter *formatter; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - formatter = [NSDateComponentsFormatter new]; - formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleShort; - formatter.maximumUnitCount = 2; - formatter.collapsesLargestUnit = YES; - formatter.includesTimeRemainingPhrase = YES; - }); - - idleString = [formatter stringFromTimeInterval: eta]; - } - else { - idleString = [NSString timeString: eta includesTimeRemainingPhrase: YES showSeconds: YES maxFields: 2]; - } - + static NSDateComponentsFormatter *formatter; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + formatter = [NSDateComponentsFormatter new]; + formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleShort; + formatter.maximumUnitCount = 2; + formatter.collapsesLargestUnit = YES; + formatter.includesTimeRemainingPhrase = YES; + }); + NSString * idleString = [formatter stringFromTimeInterval: eta]; + if (fromIdle) { idleString = [idleString stringByAppendingFormat: @" (%@)", NSLocalizedString(@"inactive", "Torrent -> eta string")]; } diff --git a/macosx/TrackerNode.m b/macosx/TrackerNode.m index f5feaf0da..27d1dd034 100644 --- a/macosx/TrackerNode.m +++ b/macosx/TrackerNode.m @@ -156,23 +156,17 @@ case TR_TRACKER_WAITING: { const NSTimeInterval nextAnnounceTimeLeft = fStat.nextAnnounceTime - [[NSDate date] timeIntervalSince1970]; - - NSString *timeString; - if ([NSApp isOnYosemiteOrBetter]) { - static NSDateComponentsFormatter *formatter; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - formatter = [NSDateComponentsFormatter new]; - formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleAbbreviated; - formatter.zeroFormattingBehavior = NSDateComponentsFormatterZeroFormattingBehaviorDropLeading; - formatter.collapsesLargestUnit = YES; - }); - - timeString = [formatter stringFromTimeInterval: nextAnnounceTimeLeft]; - } - else { - timeString = [NSString timeString: nextAnnounceTimeLeft includesTimeRemainingPhrase: NO showSeconds: YES]; - } + + static NSDateComponentsFormatter *formatter; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + formatter = [NSDateComponentsFormatter new]; + formatter.unitsStyle = NSDateComponentsFormatterUnitsStyleAbbreviated; + formatter.zeroFormattingBehavior = NSDateComponentsFormatterZeroFormattingBehaviorDropLeading; + formatter.collapsesLargestUnit = YES; + }); + + NSString *timeString = [formatter stringFromTimeInterval: nextAnnounceTimeLeft]; return [NSString stringWithFormat: NSLocalizedString(@"Next announce in %@", "Tracker next announce"), timeString]; }