39
39
static NSString *SPAboutPanelNibName = @" AboutPanel" ;
40
40
static NSString *SPShortVersionHashKey = @" SPVersionShortHash" ;
41
41
42
- static BOOL isOSAtLeast10_14 = NO ;
43
-
44
42
@interface SPAboutController ()
45
43
46
- - (BOOL )_isInDarkMode ;
47
44
- (void )_setVersionLabel : (BOOL )isNightly ;
48
- - (NSAttributedString *)_getCreditsText ;
49
- - (NSAttributedString *)_getLicenseText ;
50
- - (NSAttributedString *)_applyTextAttributes : (NSMutableAttributedString *)text ;
45
+ - (NSMutableAttributedString *)_loadRtfResource : (NSString *)filename ;
51
46
52
47
@end
53
48
54
49
@implementation SPAboutController
55
50
56
51
#pragma mark -
57
52
58
- + (void )initialize
59
- {
60
- isOSAtLeast10_14 = [SPOSInfo isOSVersionAtLeastMajor: 10 minor: 14 patch: 0 ];
61
- }
62
-
63
53
- (id )init
64
54
{
65
55
return [super initWithWindowNibName: SPAboutPanelNibName];
@@ -80,10 +70,10 @@ - (void)awakeFromNib
80
70
[self _setVersionLabel: isSnapshotBuild];
81
71
82
72
// Set the credits
83
- [[appCreditsTextView textStorage ] appendAttributedString: [self _getCreditsText ]];
73
+ [[appCreditsTextView textStorage ] appendAttributedString: [self _loadRtfResource: SPCreditsFilename ]];
84
74
85
75
// Set the license
86
- [[appLicenseTextView textStorage ] appendAttributedString: [self _getLicenseText ]];
76
+ [[appLicenseTextView textStorage ] appendAttributedString: [self _loadRtfResource: SPLicenseFilename ]];
87
77
}
88
78
89
79
#pragma mark -
@@ -109,19 +99,6 @@ - (IBAction)closeApplicationLicenseSheet:(id)sender;
109
99
#pragma mark -
110
100
#pragma mark Private API
111
101
112
- - (BOOL )_isInDarkMode
113
- {
114
- if (isOSAtLeast10_14) {
115
- NSString *match = [[NSAppearance currentAppearance ] bestMatchFromAppearancesWithNames: @[NSAppearanceNameAqua , NSAppearanceNameDarkAqua ]];
116
-
117
- if ([NSAppearanceNameDarkAqua isEqualToString: match]) {
118
- return YES ;
119
- }
120
- }
121
-
122
- return NO ;
123
- }
124
-
125
102
/* *
126
103
* Set the UI version labels.
127
104
*
@@ -154,35 +131,15 @@ - (void)_setVersionLabel:(BOOL)isSnapshotBuild
154
131
}
155
132
156
133
/* *
157
- * Returns the credits string to display in the about dialog .
134
+ * Loads the resource with the supplied name and sets any necessary string attributes .
158
135
*/
159
- - (NSAttributedString *)_getCreditsText
136
+ - (NSAttributedString *)_loadRtfResource : ( NSString *) filename
160
137
{
161
- NSMutableAttributedString *credits = [[NSMutableAttributedString alloc ] initWithPath: [[NSBundle mainBundle ] pathForResource: SPCreditsFilename ofType: @" rtf" ] documentAttributes: nil ];
162
-
163
- return [[self _applyTextAttributes: credits] autorelease ];
164
- }
138
+ NSMutableAttributedString *resouece = [[NSMutableAttributedString alloc ] initWithPath: [[NSBundle mainBundle ] pathForResource: filename ofType: @" rtf" ] documentAttributes: nil ];
165
139
166
- /* *
167
- * Returns the license string to display in the about dialog.
168
- */
169
- - (NSAttributedString *)_getLicenseText
170
- {
171
- NSMutableAttributedString *license = [[NSMutableAttributedString alloc ] initWithPath: [[NSBundle mainBundle ] pathForResource: SPLicenseFilename ofType: @" rtf" ] documentAttributes: nil ];
172
-
173
- return [[self _applyTextAttributes: license] autorelease ];
174
- }
175
-
176
- /* *
177
- *
178
- */
179
- - (NSAttributedString *)_applyTextAttributes : (NSMutableAttributedString *)text
180
- {
181
- if ([self _isInDarkMode ]) {
182
- [text addAttribute: NSForegroundColorAttributeName value: [NSColor textColor ] range: NSMakeRange (0 , [text length ])];
183
- }
140
+ [resouece addAttribute: NSForegroundColorAttributeName value: [NSColor textColor ] range: NSMakeRange (0 , [resouece length ])];
184
141
185
- return text ;
142
+ return [resouece autorelease ] ;
186
143
}
187
144
188
145
@end
0 commit comments