diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-12-22 22:41:15 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-12-22 22:41:15 -0800 |
commit | ba6edac01e1edb91cc6e8c69d942f35016b1ed84 (patch) | |
tree | b5b37fa954f12e7b5f03ab8a38183e8e85ca82a4 /platform/osx | |
parent | 7c22792bdfa1f89990736bd8ef67cb4e5e64220f (diff) | |
download | qtlocation-mapboxgl-ba6edac01e1edb91cc6e8c69d942f35016b1ed84.tar.gz |
[osx] Restore last viewed style at launch
Fixes #3389.
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/app/AppDelegate.m | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/platform/osx/app/AppDelegate.m b/platform/osx/app/AppDelegate.m index 3df79cfe0f..6aaf965357 100644 --- a/platform/osx/app/AppDelegate.m +++ b/platform/osx/app/AppDelegate.m @@ -86,6 +86,11 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { [self showPreferences:nil]; } + NSURL *savedURL = [[NSUserDefaults standardUserDefaults] URLForKey:@"MBXCurrentStyleURL"]; + if (savedURL) { + self.mapView.styleURL = savedURL; + } + _spellOutNumberFormatter = [[NSNumberFormatter alloc] init]; NSPressGestureRecognizer *pressGestureRecognizer = [[NSPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlePressGesture:)]; @@ -186,28 +191,30 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { break; } self.mapView.styleURL = styleURL; + [[NSUserDefaults standardUserDefaults] setURL:self.mapView.styleURL forKey:@"MBXCurrentStyleURL"]; [self.window.toolbar validateVisibleItems]; } - (IBAction)chooseCustomStyle:(id)sender { NSAlert *alert = [[NSAlert alloc] init]; alert.messageText = @"Apply custom style"; - alert.informativeText = @"Enter the URL to a JSON file that conforms to the Mapbox GL style specification:"; + alert.informativeText = @"Enter the URL to a JSON file that conforms to the Mapbox GL style specification, such as a style designed in Mapbox Studio:"; NSTextField *textField = [[NSTextField alloc] initWithFrame:NSZeroRect]; [textField sizeToFit]; NSRect textFieldFrame = textField.frame; textFieldFrame.size.width = 300; textField.frame = textFieldFrame; - NSString *savedURLString = [[NSUserDefaults standardUserDefaults] stringForKey:@"MBXCustomStyleURL"]; - if (savedURLString) { - textField.stringValue = savedURLString; + NSURL *savedURL = [[NSUserDefaults standardUserDefaults] URLForKey:@"MBXCustomStyleURL"]; + if (savedURL) { + textField.stringValue = savedURL.absoluteString; } alert.accessoryView = textField; [alert addButtonWithTitle:@"Apply"]; [alert addButtonWithTitle:@"Cancel"]; if ([alert runModal] == NSAlertFirstButtonReturn) { - [[NSUserDefaults standardUserDefaults] setObject:textField.stringValue forKey:@"MBXCustomStyleURL"]; self.mapView.styleURL = [NSURL URLWithString:textField.stringValue]; + [[NSUserDefaults standardUserDefaults] setURL:self.mapView.styleURL forKey:@"MBXCustomStyleURL"]; + [[NSUserDefaults standardUserDefaults] setURL:self.mapView.styleURL forKey:@"MBXCurrentStyleURL"]; [self.window.toolbar validateVisibleItems]; } } |