mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 15:12:21 +00:00
Fixed #69
Opene Files will block the reopening mechanism. Restored windows will still be reopened, but the open file will be the front most window.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
MPLockDaemon *lockDaemon;
|
||||
MPAutotypeDaemon *autotypeDaemon;
|
||||
BOOL _restoredWindows;
|
||||
BOOL _shouldOpenFile;
|
||||
}
|
||||
|
||||
@property (strong, nonatomic) MPSettingsWindowController *settingsController;
|
||||
@@ -55,6 +56,7 @@
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
||||
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
||||
_restoredWindows = NO;
|
||||
_shouldOpenFile = NO;
|
||||
if(reopen) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_applicationDidFinishRestoringWindows:)
|
||||
@@ -64,13 +66,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
|
||||
_shouldOpenFile = YES;
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:filename];
|
||||
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:fileURL display:YES completionHandler:nil];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
|
||||
serverDaemon = [[MPServerDaemon alloc] init];
|
||||
lockDaemon = [[MPLockDaemon alloc] init];
|
||||
//autotypeDaemon = [[MPAutotypeDaemon alloc] init];
|
||||
|
||||
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
||||
if(reopen && !_restoredWindows) {
|
||||
if(reopen && !_restoredWindows && !_shouldOpenFile) {
|
||||
NSDocumentController *documentController = [NSDocumentController sharedDocumentController];
|
||||
NSArray *documents = [documentController documents];
|
||||
if([documents count] > 0) {
|
||||
|
||||
Reference in New Issue
Block a user