More progress on import plugin support

This commit is contained in:
Michael Starke
2018-10-25 16:34:35 +02:00
parent 5912f613cb
commit 38e7a5f0b9
10 changed files with 109 additions and 25 deletions

View File

@@ -40,6 +40,9 @@
#import "MPToolbarDelegate.h"
#import "MPTitlebarColorAccessoryViewController.h"
#import "MPPluginHost.h"
#import "MPPlugin.h"
#import "KeePassKit/KeePassKit.h"
typedef NS_ENUM(NSUInteger, MPAlertContext) {
@@ -274,6 +277,28 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
}];
}
- (void)importFromPlugin:(id)sender {
if(![sender isKindOfClass:NSMenuItem.class]) {
return;
}
NSMenuItem *menuItem = sender;
if(![menuItem.representedObject isKindOfClass:NSDictionary.class]) {
return;
}
NSWindow *sheetWindow = ((MPDocument *)self.document).windowForSheet;
if(!sheetWindow) {
return;
}
MPPlugin<MPImportPlugin> *importPlugin;
NSOpenPanel *openPanel = NSOpenPanel.openPanel;
[importPlugin prepareOpenPanel:openPanel];
[openPanel beginSheetModalForWindow:sheetWindow completionHandler:^(NSModalResponse result) {
KPKTree *importedTree = [importPlugin treeForRunningOpenPanel:openPanel withResponse:result];
[self.document importTree:importedTree];
}];
}
- (void)mergeWithOther:(id)sender {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
MPDocument *document = self.document;