mirror of
https://github.com/transmission/transmission
synced 2025-01-30 19:03:04 +00:00
Remove pre-10.10 codepaths
This commit is contained in:
parent
b83d8e4832
commit
74189416c6
21 changed files with 87 additions and 390 deletions
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 401 B |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
|
@ -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"
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 413 B |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
|
@ -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"
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 434 B |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
@interface NSApplication (NSApplicationAdditions)
|
||||
|
||||
- (BOOL) isOnYosemiteOrBetter;
|
||||
- (BOOL) isOnMojaveOrBetter;
|
||||
- (BOOL) isDarkMode;
|
||||
|
||||
|
|
|
@ -24,11 +24,6 @@
|
|||
|
||||
@implementation NSApplication (NSApplicationAdditions)
|
||||
|
||||
- (BOOL) isOnYosemiteOrBetter
|
||||
{
|
||||
return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9;
|
||||
}
|
||||
|
||||
- (BOOL) isOnMojaveOrBetter
|
||||
{
|
||||
return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_13;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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")];
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue