mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-18 18:19:28 +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;
|
MPLockDaemon *lockDaemon;
|
||||||
MPAutotypeDaemon *autotypeDaemon;
|
MPAutotypeDaemon *autotypeDaemon;
|
||||||
BOOL _restoredWindows;
|
BOOL _restoredWindows;
|
||||||
|
BOOL _shouldOpenFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (strong, nonatomic) MPSettingsWindowController *settingsController;
|
@property (strong, nonatomic) MPSettingsWindowController *settingsController;
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
||||||
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
||||||
_restoredWindows = NO;
|
_restoredWindows = NO;
|
||||||
|
_shouldOpenFile = NO;
|
||||||
if(reopen) {
|
if(reopen) {
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(_applicationDidFinishRestoringWindows:)
|
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 {
|
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
|
||||||
serverDaemon = [[MPServerDaemon alloc] init];
|
serverDaemon = [[MPServerDaemon alloc] init];
|
||||||
lockDaemon = [[MPLockDaemon alloc] init];
|
lockDaemon = [[MPLockDaemon alloc] init];
|
||||||
//autotypeDaemon = [[MPAutotypeDaemon alloc] init];
|
//autotypeDaemon = [[MPAutotypeDaemon alloc] init];
|
||||||
|
|
||||||
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
||||||
if(reopen && !_restoredWindows) {
|
if(reopen && !_restoredWindows && !_shouldOpenFile) {
|
||||||
NSDocumentController *documentController = [NSDocumentController sharedDocumentController];
|
NSDocumentController *documentController = [NSDocumentController sharedDocumentController];
|
||||||
NSArray *documents = [documentController documents];
|
NSArray *documents = [documentController documents];
|
||||||
if([documents count] > 0) {
|
if([documents count] > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user