From 74189416c614b8f5bdcbf86ed582e66fc464b39a Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 22 Dec 2020 22:00:06 -0500 Subject: [PATCH] Remove pre-10.10 codepaths --- macosx/Controller.m | 10 +- macosx/FilterBarView.m | 66 ++--------- .../PurpleDotGlossy.imageset/Contents.json | 21 ---- .../PurpleDotGlossy.png | Bin 401 -> 0 bytes .../PurpleDotGlossy@2x.png | Bin 1288 -> 0 bytes .../RedDotGlossy.imageset/Contents.json | 21 ---- .../RedDotGlossy.imageset/RedDotGlossy.png | Bin 413 -> 0 bytes .../RedDotGlossy.imageset/RedDotGlossy@2x.png | Bin 1213 -> 0 bytes .../YellowDotGlossy.imageset/Contents.json | 21 ---- .../YellowDotGlossy.png | Bin 434 -> 0 bytes .../YellowDotGlossy@2x.png | Bin 1270 -> 0 bytes macosx/InfoActivityViewController.m | 32 +++-- macosx/MessageWindowController.m | 12 +- macosx/NSApplicationAdditions.h | 1 - macosx/NSApplicationAdditions.m | 5 - macosx/NSStringAdditions.h | 3 - macosx/NSStringAdditions.m | 60 ---------- macosx/StatsWindowController.m | 34 +++--- macosx/StatusBarView.m | 110 ++++-------------- macosx/Torrent.m | 53 +++------ macosx/TrackerNode.m | 28 ++--- 21 files changed, 87 insertions(+), 390 deletions(-) delete mode 100644 macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/Contents.json delete mode 100644 macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/PurpleDotGlossy.png delete mode 100644 macosx/Images/Images.xcassets/PurpleDotGlossy.imageset/PurpleDotGlossy@2x.png delete mode 100644 macosx/Images/Images.xcassets/RedDotGlossy.imageset/Contents.json delete mode 100644 macosx/Images/Images.xcassets/RedDotGlossy.imageset/RedDotGlossy.png delete mode 100644 macosx/Images/Images.xcassets/RedDotGlossy.imageset/RedDotGlossy@2x.png delete mode 100644 macosx/Images/Images.xcassets/YellowDotGlossy.imageset/Contents.json delete mode 100644 macosx/Images/Images.xcassets/YellowDotGlossy.imageset/YellowDotGlossy.png delete mode 100644 macosx/Images/Images.xcassets/YellowDotGlossy.imageset/YellowDotGlossy@2x.png 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 58deefaae65fd62db80c27517c4b5bd16472f96e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 401 zcmV;C0dD?@P)#kmPS=!p*?UjtmEvGXo2jC~Hmk`8C_0ju5x2 zvEp+#S$yxO2r#oF!@=du(1J~7`~6#NPK0ukIA4z8P#^5baBxQ|*rH(?lH<83aXKH( zp}sQyCd0uU?FGM(cs93s-$?@TxE{|=$Z$q_!Q!6(>$ug?U~g`Ve4HmKKgvO3-xTo@ zA;al$7Z3d!mnmD7iz*sBoQW*(x|P@g%)vfLcY00%os|GP&6(XSog3%B{l_8iu6L#K4F;|44?#TsXVR~F| z(y9fs8|zl}eAR$VYEIlILkGipnnmymKcp>D94(^%Mn4{&d5A}6AK~%Y$9Q!5q01FV z3iQycG6^v2m*GR%^xXJ|-X%Zu=@V9RpI?hbf-(Wi3BVb5kn7E1@WvpXo_&I+=bobX zaxZ$X^y2CHCoV^g9(tK!R&|8qW@2yoUE*^G=$7>E_R9zYTGahj_Na}5Dj$6?ilIA0 z7`i>Eu4UXFaye@B(8~<7>|hr=KWBg_bEYAziC!6mC4A6@4oww0IR}N|JaU6M&(8IRes!(%u3&YJwr0h#hn=e@ZH#bk~A)T4xjG6`eH)!b#H&qa7O0BraWBRt?D2f5Ig zcjq3$4g7xsayTPtH9A|@qWR8TyhK43Qe484B`GDP2}Pw`P)YXl0>Xw5F>t^|4suze z>$}m>3Qf_@09^qQ&}x2fnGc6;GhHK>drB73y3v>TNRXY}oK21`dIX zoG<2wz0>yGG!gltnJ_ZlB}}E-fZ+`khKJs)KRwvvzMGtihiQcjGRyhUN{5P7E&v-o z#0VU4Ip@$oVQ5GWhgPJlfHtxMmtg_J#j*ag(`UB6GH)Geb)T&agl#mIjM8K_1;8fw z+BgOdbGLEMfaC)%GH5;i-FH_{wLH&VyaK?6@5I!x z&EWi&=ZaP;&=x?-6g)4%P);e-Wupqi2^3;mQwUf!{MLw@SxCGSa@R+f~F0i8mQ=1~sXRvySgkB|+dJFCX ze0a>*Vb?W~+!ATCbPopL4ZMR7@CZ%;JM20y*cRDs(ZabJiKwPhLt-)2Y*v}EGUh1Zop&44!f@ZfdLa> z2F!s4ut)+;j~P2AJm4CM1>ck+)bzq1b`FdTSuhqrZCu@Ni!|CD4E19G00000NkvXX Hu0mjfN)oZD 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 1e30550a4ff69c126443f8e414d54d3ad3ae615d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1213 zcmV;u1Va0XP)R=R%0!A>V7sv&)S`I*#BvBN-m06!{4H|3Pwr$(CZCk-rXaj2_xZzmaw*9TzduLv| zf7hrY&Qwm;d-oyHALu*>IOC!qc=%hPNqWt>n$UXiz z@=rbqk$d6^lwN%m_~#$UCTl+OrN(LdQ>$65uvzQ-fg|YL*&0R2RIBj$Jn+L0sMTsH zee@B6kgfqu`CU)M`5KeMufIaJ@{un!I;eFxfIDPn#3m4?fkWwxR+4Bm;3@7X82$AZ zs%$U3r=@jPNwD&$T!t$Y;Q#v%@{zAJqy^v}(uhkSuvR6Lz^WMl8Rw7^4B{zX=b8r! z%(-z1FkmDbzGW+)jNtzhz-oYAsLNW!C6LgEq)>40B{*6srhiiABi|$wkd`G-fjzMa z=pQcwRw*Gztn#K?IwI7pw_TZNEHu`f#ChzPUIpIO z9wdL*yKG6s{?1F1b}~p-BO8%z_62UeCJ27M&$;N4FpQo~CdHhw=JZWA0JbHYkX6WH zrj?kFUtsXog>JHxC9yHtnry!|aLUfW)kgpi35_)eU@s?y$*_iF(RzTLYf@YOAf5se3qc-MUH7d5riljjPGx9c9o&0Bb z{yUK*t=5g%R^8HMSz%+%^_xu_Nex#X7a%qX!x^CoI|Ei-eVAsKPJ9A!i5N}(u#638 b#6SN7S9$vgm=g&^00000NkvXXu0mjf*6~iC 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 6e46203a163f55433e11fd84dbf2ff0a940390ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 434 zcmV;j0ZsmiP)0JSU%qwu%)-DhmuX1&-m-F zb=La!I%2`bAsksdn2%a%dCH*nv6(c>PfoY~+pZ-(KDW+mrR6CTQ{&;?qgi}zp7F`a zrQW|d?)~rEUMnq6nV9k=L0|w^V3^!?dNx0x{qnVNgM1jF11~8ar&=|5&9KY<<9H@xT5e zCKTiWlrOM0;&xJ(@vg;B5RwWjFoNVgh^g)y0A&9~Tp$5j0WE;`9iU@xXdXNd|LSr< zY~=zE6fM}wu}81j5kCc*O@wxHq4gqYIum)1-mqiAW{!ykJe9@)ErFrORx0j}g; z>-;14-k=|^4|C<%YSt(VjHAkgKM@|bACLw{giQxeSrk}mD`^z&)K)7kulB=Li)^|7 cU~4*93^{vXm59lq7nd2U7SbM>DMr)mu!4FB*oadc! z>pm~h2M2V}^)s*2iPcZ)%+AkscK_dmF>~Bwjb<%1Lm!qZ&Y#Oabb~@*&wAD#x8ciT zeQbCK9bbHl_IAFl)#=GvXHRRbJi?ec?y-ioni^{9k!uJ$?3VK|^$F{f$~yP{+BQW} z(V{|%s_VolZ6j7mFA*0Pr;;FnxRN>Uv4*um4Yl;3*TudA)(^K^HKpawi&f3@q@vE1 z!V(UaLBo2H_%f0D;UW#A2;vdQEfw+4peD^)YJ^&Ny!0cya82jz<%V3n-J_-TM0vGa zSzhBxQHc`K4IV9%)}W$^RCyR6j+)b~rADZY)%z7aTB^s9`~}vUE9U^_cDcnx z)}tkrj+9k7VmTS;lQ3_@@i3Yfpu_=o&>i?Vq;UY+gXXN39`r)NAEq#TfZ*yuenFwt zx46uf{32#NKw}>bY{F^^f`29Bt8f6e!y%zXb9xk7{jiw_{NOHx-GN|$yu5r{3W{v8 zTo^h&vVcuAkHqvm$6_rt)Y5}qW`Imka^3-K8y(bk&=@WH(F@Jv#@pfw9)sKD`4gL@ z()x&((XE0j7sutRiJd~6vqS^HLm=hzS1A!MA>w;X2|NT|hlA!9{5f!{QLReG6g*i1 zEDYcji4@j|l(YwJ5VsI10*smCo>RzLYN!=@oQbHFG|f4H#tK59mhV;*8c${=o8(zg zX6{CQIU2VTDK;=>PMn|zHPBi@j}^PsMEa84cfd3U{ zf9@qYv3V~5W9C%a)M#p?;g~1zSo_s{y@H;`TXUUnfGqiauJ^_MZRuG26wcDjq(Gxc z>I68BIAYEbGsl=UsHKM5U*~vV8b1%H3%vswkes?h_WwF9`|8fssaWC!Gd>zc0Z!rv zMWVaG9>&aZk2R9OJk32cc?|^(z4%&cz;3{y-mv=iq zE_=V=*nxjbb^WMv9h+D|7;EOZ_Z4bTdn>pG^a1URS01pN_OndWrr(H;5fp<;PzuUG zA#fk+C0)C;u$y{~*y=!4NbvM)lx~xvEAGVcx*F(d^Y5B1W4D zo_+WL;Y0YwAYlyI;50bJV+i$Ts6=q*!kTkgVS6Fp5yS;faNgt*7|#8nbKwKz7=(m; gu_&Me^aUFK2N{?Q=-tDi8vp 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]; }