Skip to content

Commit c5dbc35

Browse files
committed
Merge remote-tracking branch 'origin/nopod' into nopod
2 parents 5edddc6 + df74c5d commit c5dbc35

17 files changed

+585
-212
lines changed

EnterDetailsWindow.xib

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
<objects>
88
<customObject id="-2" userLabel="File's Owner" customClass="EnterDetailsWindowController">
99
<connections>
10+
<outlet property="addStudyDaysCheck" destination="4Ka-Zc-HA6" id="vPD-su-Erv"/>
11+
<outlet property="addStudyNameCheck" destination="Xpl-Jh-tfm" id="KJj-qm-zCk"/>
1012
<outlet property="ageField" destination="uIx-CI-to5" id="th4-9J-ESp"/>
1113
<outlet property="caseTitleField" destination="Bhe-6Y-W2c" id="bd2-DZ-DL8"/>
1214
<outlet property="caserIDField" destination="FKb-KN-Vwc" id="YTP-te-bTq"/>
15+
<outlet property="compressionSlider" destination="f9z-sg-9lb" id="S0v-ji-dyd"/>
16+
<outlet property="compressionValueField" destination="B1d-b1-Pe3" id="SB8-8b-Wle"/>
1317
<outlet property="discussionField" destination="m9y-gZ-9RL" id="rb5-rL-dap"/>
1418
<outlet property="genderSelect" destination="D2L-dq-VUC" id="ygM-uI-958"/>
19+
<outlet property="logoutButton" destination="bbb-Uh-1Ma" id="wto-j1-gmF"/>
20+
<outlet property="okButton" destination="g0K-Wk-NbD" id="IHY-8c-mfR"/>
1521
<outlet property="presentationField" destination="zIQ-Yr-Y2P" id="vmA-eq-Rei"/>
1622
<outlet property="systemSelect" destination="ZkH-Wz-CKe" id="rD5-Jg-ThQ"/>
1723
<outlet property="textField" destination="Bhe-6Y-W2c" id="IsX-p1-EHs"/>
@@ -20,7 +26,7 @@
2026
</customObject>
2127
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
2228
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
23-
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
29+
<window title="Case details" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
2430
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
2531
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
2632
<rect key="contentRect" x="196" y="240" width="582" height="524"/>
@@ -196,5 +202,37 @@ Gw
196202
<menuItem title="Item 2" id="8gm-Cb-vy2"/>
197203
<menuItem title="Item 3" id="ZqO-C3-vq0"/>
198204
<menuItem title="Item 3" id="vmh-Vn-XvZ"/>
205+
<slider verticalHuggingPriority="750" id="f9z-sg-9lb">
206+
<rect key="frame" x="0.0" y="0.0" width="199" height="19"/>
207+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
208+
<sliderCell key="cell" state="on" alignment="left" maxValue="1" doubleValue="0.5" tickMarkPosition="above" sliderType="linear" id="VZa-7T-lJD"/>
209+
<connections>
210+
<action selector="sliderValueChanged:" target="-2" id="Rty-7A-mXT"/>
211+
</connections>
212+
<point key="canvasLocation" x="1117" y="484"/>
213+
</slider>
214+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="B1d-b1-Pe3">
215+
<rect key="frame" x="0.0" y="0.0" width="23" height="17"/>
216+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
217+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="0.5" id="hjt-Bb-GLp">
218+
<font key="font" metaFont="system"/>
219+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
220+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
221+
</textFieldCell>
222+
<point key="canvasLocation" x="1104" y="533"/>
223+
</textField>
224+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="kV9-wj-HhL">
225+
<rect key="frame" x="0.0" y="0.0" width="88" height="17"/>
226+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
227+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Compression:" id="HWr-86-0Nx">
228+
<font key="font" metaFont="system"/>
229+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
230+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
231+
</textFieldCell>
232+
<point key="canvasLocation" x="1100" y="418"/>
233+
</textField>
199234
</objects>
235+
<resources>
236+
<image name="Info-Button" width="2382" height="2382"/>
237+
</resources>
200238
</document>

EnterDetailsWindowController.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@
2020
{
2121

2222
}
23-
23+
- (IBAction)openTipsAndTricks:(id)sender;
24+
@property (strong) NSArray *titles;
25+
@property (strong) NSArray *indexOfSelected;
26+
-(long) getSelectedIndex;
2427
- (void)windowDidLoad;
2528
-(void) awakeFromNib;
29+
@property (strong) IBOutlet NSTextField *supportLabel;
30+
@property (strong) IBOutlet NSButton *addStudyNameCheck;
31+
@property (strong) IBOutlet NSButton *addStudyDaysCheck;
2632
@property (strong) id parent;
33+
@property (strong) IBOutlet NSButton *logoutButton;
34+
@property (strong) IBOutlet NSButton *okButton;
35+
@property (strong) IBOutlet NSSlider *compressionSlider;
36+
@property (strong) IBOutlet NSTextField *compressionValueField;
2737
@property (strong) IBOutlet NSTextField *caserIDField;
2838
@property (strong) IBOutlet NSTextField *caseTitleField;
2939
@property (strong) IBOutlet NSPopUpButton *systemSelect;
@@ -32,4 +42,4 @@
3242
@property (strong) IBOutlet NSTextField *presentationField;
3343
@property (strong) IBOutlet NSTextField *discussionField;
3444
- (void)setupSheetTerminationHandling ;
35-
@end
45+
@end

EnterDetailsWindowController.m

Lines changed: 108 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,128 @@ -(void) awakeFromNib
1818

1919

2020
}
21+
-(bool) checkTextField:(NSTextField *)field
22+
{
23+
24+
return (([field stringValue] != nil) && ([[field stringValue] length] > 0));
25+
}
26+
-(bool) checkTextFieldContainsNumeric:(NSTextField *)field
27+
{
28+
NSString *s = [field stringValue];
29+
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
30+
return !([numberFormatter numberFromString:s] == nil);
31+
32+
}
33+
-(void) updateOKButton
34+
{
35+
if (([self checkTextField:self.caserIDField] && [self checkTextFieldContainsNumeric:self.caserIDField])|| ([self checkTextField:self.caseTitleField] && ![self checkTextFieldContainsNumeric:self.caseTitleField]))
36+
{
37+
[self.okButton setEnabled:true];
38+
}
39+
else
40+
[self.okButton setEnabled:false];
41+
}
42+
- (void)controlTextDidChange:(NSNotification *)notification {
43+
[self updateOKButton];
44+
}
45+
2146
- (IBAction)OkButtonClicked:(id)sender {
2247
[self.window.sheetParent endSheet:self.window returnCode:NSModalResponseOK];
2348
}
2449
- (IBAction)CancelButtonClicked:(id)sender {
2550
[self.window.sheetParent endSheet:self.window returnCode:NSModalResponseCancel];
2651
}
52+
- (IBAction)LogoutButtonClicked:(id)sender {
53+
[GTMOAuth2WindowController removeAuthFromKeychainForName:KEYCHAIN_ITEM];
54+
NSAlert *myAlert = [[NSAlert alloc] init];
55+
[myAlert setMessageText:@"You have been logged out"];
56+
RadiopaediaFilter *p = (RadiopaediaFilter *)self.parent;
57+
p.isSignedIn = false;
58+
[self.logoutButton setEnabled:false];
59+
[myAlert performSelectorOnMainThread:@selector(runModal) withObject:nil waitUntilDone:NO];
60+
[self.window.sheetParent endSheet:self.window returnCode:NSModalResponseCancel];
61+
}
62+
-(long) getSelectedIndex
63+
{
64+
65+
int s = (int )[self.systemSelect indexOfSelectedItem];
66+
long ret = (long)[(NSNumber *)[self.indexOfSelected objectAtIndex:s] intValue];
67+
return ret;
68+
}
2769
- (void)windowDidLoad
2870
{
29-
3071

3172

73+
RadiopaediaFilter *p = (RadiopaediaFilter *)self.parent;
74+
if ([p isSignedIn])
75+
{
76+
[self.logoutButton setEnabled:true];
77+
}
78+
self.caseTitleField.delegate = self;
79+
self.caserIDField.delegate = self;
80+
self.indexOfSelected = @[@1,@2,@3,@4,@6,@7,@8,@9,@11,@12,@15,@16,@17,@18,@19,@20,@21,@22,@23];
81+
self.titles = @[@"",
82+
@"Breast",
83+
@"Vascular",
84+
@"Central Nervous System",
85+
@"Chest",
86+
@"",
87+
@"Gastrointestinal",
88+
@"Head and Neck",
89+
@"Hepatobiliary",
90+
@"Musculoskeletal",
91+
@"",
92+
@"Urogenital",
93+
@"Paediatrics",
94+
@"",
95+
@"",
96+
@"Spine",
97+
@"Cardiac",
98+
@"Interventional",
99+
@"Obstetrics",
100+
@"Gynaecology",
101+
@"Haematology",
102+
@"Forensic",
103+
@"Oncology",
104+
@"Trauma"];
105+
106+
self.titles = @[@"Breast",
107+
@"Vascular",
108+
@"Central Nervous System",
109+
@"Chest",
110+
@"Gastrointestinal",
111+
@"Head and Neck",
112+
@"Hepatobiliary",
113+
@"Musculoskeletal",
114+
@"Urogenital",
115+
@"Paediatrics",
116+
@"Spine",
117+
@"Cardiac",
118+
@"Interventional",
119+
@"Obstetrics",
120+
@"Gynaecology",
121+
@"Haematology",
122+
@"Forensic",
123+
@"Oncology",
124+
@"Trauma"];
125+
126+
32127
[super windowDidLoad];
33-
NSArray *titles = @[@"Empty1",
34-
@"Breast",
35-
@"Vascular",
36-
@"Central Nervous System",
37-
@"Chest",
38-
@"Empty2",
39-
@"Gastrointestinal",
40-
@"Head and Neck",
41-
@"Hepatobiliary",
42-
@"Musculoskeletal",
43-
@"Empty3",
44-
@"Urogenital",
45-
@"Paediatrics",
46-
@"Empty4",
47-
@"Spine",
48-
@"Cardiac",
49-
@"Interventional",
50-
@"Obstetrics",
51-
@"Gynaecology",
52-
@"Haematology",
53-
@"Empty5",
54-
@"Forensic",
55-
@"Oncology",
56-
@"Trauma"];
57-
for (NSString *title in titles)
128+
129+
for (NSString *title in self.titles)
58130
{
59131
[self.systemSelect addItemWithTitle:title];
60132
}
61133
[self.window makeFirstResponder:self.caseTitleField];
62134
[self.ageField setStringValue:((RadiopaediaFilter *)self.parent).patientAge];
63135
[self.genderSelect selectItemWithTitle:((RadiopaediaFilter *)self.parent).patientSex];
64136
}
137+
- (IBAction)supportButton:(id)sender {
138+
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://radiopaedia.org/supporters"]];
139+
}
140+
- (IBAction)sliderValueChanged:(id)sender {
141+
[self.compressionValueField setStringValue:[NSString stringWithFormat:@"%f", [self.compressionSlider floatValue]]];
142+
}
65143
- (void)setupSheetTerminationHandling {
66144
NSWindow *sheet = [self window];
67145

@@ -78,4 +156,7 @@ - (void)setupSheetTerminationHandling {
78156
[invocation invoke];
79157
}
80158
}
81-
@end
159+
- (IBAction)openTipsAndTricks:(id)sender {
160+
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://radiopaedia.org/blog/radiopaedia-case-uploader-plugin-for-horos-osirix"]];
161+
}
162+
@end

FinishedWindow.xib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<outlet property="hyperlinkLabel" destination="Xps-8L-rk9" id="bXd-Tl-OT9"/>
1111
<outlet property="ridLabel" destination="e2s-g1-ad2" id="fxn-ho-uNN"/>
1212
<outlet property="seriesLabel" destination="e2s-g1-ad2" id="eAK-J1-ppX"/>
13+
<outlet property="statusLabel" destination="oQ9-cy-t7q" id="dMK-FX-hLl"/>
1314
<outlet property="window" destination="QvC-M9-y7g" id="hfp-52-0fJ"/>
1415
</connections>
1516
</customObject>

FinishedWindowController.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
}
1515
- (void)windowDidLoad;
1616
@property (strong) id parent;
17+
@property (strong) NSString *statusCode;
18+
@property (strong) IBOutlet NSTextField *statusLabel;
1719
@property (strong) IBOutlet NSTextField *ridLabel;
1820
@property (strong) IBOutlet NSTextView *hyperlinkLabel;
19-
@end
21+
@end

FinishedWindowController.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ - (IBAction)OkButtonClicked:(id)sender {
1717
}
1818
- (void)windowDidLoad
1919
{
20-
[self.ridLabel setStringValue:((RadiopaediaFilter *)(self.parent)).caseId];
21-
NSString *s = [NSString stringWithFormat:@"http://sandbox.radiopaedia.org/cases/%@", ((RadiopaediaFilter *)(self.parent)).caseId];
20+
if (((RadiopaediaFilter *)(self.parent)).caseId != nil)
21+
{
22+
23+
[self.statusLabel setStringValue:self.statusCode];
24+
NSString *original = [NSString stringWithFormat:@"%@", ((RadiopaediaFilter *)(self.parent)).caseId];
25+
NSString *replaced = [original stringByReplacingOccurrencesOfString:@"," withString:@""];
26+
[self.ridLabel setStringValue:replaced];
27+
NSString *s = [NSString stringWithFormat:@"https://radiopaedia.org/cases/%@", ((RadiopaediaFilter *)(self.parent)).caseId];
2228

2329
[self.hyperlinkLabel setAutomaticLinkDetectionEnabled:TRUE];
2430

2531
[self.hyperlinkLabel setString:s];
2632
[self.hyperlinkLabel checkTextInDocument:nil];
27-
33+
}
2834
}
29-
@end
35+
@end

GTMOAuth2Authentication.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#if GTM_INCLUDE_OAUTH2 || !GDATA_REQUIRE_SERVICE_INCLUDES
1717

1818
#import "GTMOAuth2Authentication.h"
19-
19+
#import "GTMOAuth2WindowController.h"
2020
// Extern strings
2121

2222
NSString *const kGTMOAuth2ServiceProviderGoogle = @"Google";
@@ -487,6 +487,11 @@ - (void)auth:(GTMOAuth2Authentication *)auth
487487
// Successful refresh.
488488
noteName = kGTMOAuth2AccessTokenRefreshed;
489489
userInfo = nil;
490+
491+
// Jarrel's modification
492+
// Save the new refresh token to the keychain else the next time you request a refresh radiopaedia will say that the old refresh token has expired
493+
[GTMOAuth2WindowController saveAuthToKeychainForName:KEYCHAIN_ITEM authentication:auth];
494+
490495
} else {
491496
// Google's OAuth 2 implementation returns a 400 with JSON body
492497
// containing error key "invalid_grant" to indicate the refresh token

GTMOAuth2SignIn.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ - (BOOL)startWebRequest {
317317
// we want notification if we lose connectivity to the web server
318318
[self startReachabilityCheck];
319319
return YES;
320+
320321
}
321322

322323
// utility for making a request from an old URL with some additional parameters
@@ -404,7 +405,7 @@ - (BOOL)requestRedirectedToRequest:(NSURLRequest *)redirectedRequest {
404405
&& [[redirectURL pathComponents] isEqual:[[requestURL pathComponents] subarrayWithRange:range] ]; // remove last component for comparison
405406
} else if (requestURL) {
406407
// handle "about:blank"
407-
isCallback = [redirectURL isEqual:requestURL];
408+
isCallback = [redirectURL isEqual:requestURL];
408409
} else {
409410
isCallback = NO;
410411
}
@@ -418,7 +419,15 @@ - (BOOL)requestRedirectedToRequest:(NSURLRequest *)redirectedRequest {
418419

419420
// try to get the access code
420421
if (!self.hasHandledCallback) {
421-
self.authentication.code = [[[redirectedRequest URL] pathComponents] lastObject];
422+
423+
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
424+
for (NSString *param in [[[redirectedRequest URL] query] componentsSeparatedByString:@"&"]) {
425+
NSArray *elts = [param componentsSeparatedByString:@"="];
426+
if([elts count] < 2) continue;
427+
[params setObject:[elts lastObject] forKey:[elts firstObject]];
428+
}
429+
430+
self.authentication.code = [params valueForKey:@"code"];
422431

423432
#if DEBUG
424433
NSAssert([self.authentication.code length] > 0

GTMOAuth2WindowController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ - (void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDa
499499
}
500500

501501
- (void)webView:(WebView *)sender resource:(id)identifier didFailLoadingWithError:(NSError *)error fromDataSource:(WebDataSource *)dataSource {
502-
[self.signIn loadFailedWithError:error];
502+
[self.signIn loadFailedWithError:error];
503503
}
504504

505505
- (void)windowWillClose:(NSNotification *)note {

Info-Button.png

50.9 KB
Loading

0 commit comments

Comments
 (0)