Added simple support for import Plugins via plugin API

This commit is contained in:
Michael Starke
2019-07-15 12:23:32 +02:00
parent 9a55559e71
commit 9d0dc1630d
2 changed files with 6 additions and 2 deletions

View File

@@ -249,8 +249,11 @@ typedef NS_OPTIONS(NSInteger, MPAppStartupState) {
for(MPPlugin<MPImportPlugin> * plugin in MPPluginHost.sharedHost.importPlugins) {
NSMenuItem *importItem = [[NSMenuItem alloc] init];
[plugin prepareImportMenuItem:importItem];
importItem.submenu = nil; // kill any potential submenu!
importItem.representedObject = plugin.identifier;
importItem.target = nil;
importItem.action = @selector(importFromPlugin:);
[menu addItem:importItem];
}
[menu insertItem:exportXML atIndex:0];
}

View File

@@ -284,7 +284,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
return;
}
NSMenuItem *menuItem = sender;
if(![menuItem.representedObject isKindOfClass:NSDictionary.class]) {
if(![menuItem.representedObject isKindOfClass:NSString.class]) {
return;
}
@@ -292,7 +292,8 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
if(!sheetWindow) {
return;
}
MPPlugin<MPImportPlugin> *importPlugin;
NSString *bundleIdentifier = menuItem.representedObject;
MPPlugin<MPImportPlugin> *importPlugin = (MPPlugin<MPImportPlugin> *)[MPPluginHost.sharedHost pluginWithBundleIdentifier:bundleIdentifier];
NSOpenPanel *openPanel = NSOpenPanel.openPanel;
[importPlugin prepareOpenPanel:openPanel];
[openPanel beginSheetModalForWindow:sheetWindow completionHandler:^(NSModalResponse result) {