| 25 | } |
| 26 | |
| 27 | bool LinglongPlugin::start() |
| 28 | { |
| 29 | qInfo() << __FUNCTION__; |
| 30 | // language register. |
| 31 | LanguageService *languageService = dpfGetService(LanguageService); |
| 32 | if (languageService) { |
| 33 | QString errorString; |
| 34 | bool ret = languageService->regClass<LLGenerator>(LLGenerator::toolKitName(), &errorString); |
| 35 | if (!ret) { |
| 36 | qCritical() << errorString; |
| 37 | } else { |
| 38 | ret = languageService->create<LLGenerator>(LLGenerator::toolKitName(), &errorString); |
| 39 | if (!ret) { |
| 40 | qCritical() << errorString; |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // project register. |
| 46 | ProjectService *projectService = dpfGetService(ProjectService); |
| 47 | if (projectService) { |
| 48 | QString errorString; |
| 49 | projectService->implGenerator<LLProjectGenerator>(LLProjectGenerator::toolKitName(), &errorString); |
| 50 | } |
| 51 | |
| 52 | //builder register |
| 53 | BuilderService *builderService = dpfGetService(BuilderService); |
| 54 | if (builderService) { |
| 55 | QString errorString; |
| 56 | bool ret = builderService->regClass<LLBuilderGenerator>(LLBuilderGenerator::toolKitName(), &errorString); |
| 57 | if (ret) { |
| 58 | builderService->create<LLBuilderGenerator>(LLBuilderGenerator::toolKitName(), &errorString); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | QAction *action = new QAction(QIcon::fromTheme("linglong"), LL_NAME, this); |
| 63 | windowService = dpfGetService(WindowService); |
| 64 | if (!windowService) |
| 65 | return false; |
| 66 | |
| 67 | windowService->addNavigationItem(new AbstractAction(action), Priority::low); |
| 68 | std::function<AbstractWidget *()> findCreator = []() -> AbstractWidget * { |
| 69 | return new AbstractWidget(new MainFrame()); |
| 70 | }; |
| 71 | |
| 72 | // mainFrame will setParent when register to windowService |
| 73 | windowService->registerWidgetCreator(LL_NAME, findCreator); |
| 74 | |
| 75 | connect(action, &QAction::triggered, this, [=]() { |
| 76 | windowService->showWidgetAtPosition(LL_NAME, Position::FullWindow, true); |
| 77 | windowService->showContextWidget(); |
| 78 | MainFrame::checkToolInstalled("ll-cli"); |
| 79 | }, Qt::DirectConnection); |
| 80 | |
| 81 | return true; |
| 82 | } |
| 83 | |
| 84 | dpf::Plugin::ShutdownFlag LinglongPlugin::stop() |
no test coverage detected